Angular/Nodejs 中未引用的函数错误

Unrefrenced function Error in Angular/Nodejs

我对通过 onclick() 附加到按钮的功能有疑问。我已经使用 UI-routing 将控制器附加到带有离子标签的 html 页面。这是代码片段 --

app.js

var havyakkaMaduve  = angular.module('havyakka_maduve',     ['ionic','ngStorage','ngCordova','ngCordovaOauth'])

havyakkaMaduve.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider

  // setup an abstract state for the tabs directive
    .state('home', {
    url: '/',
    templateUrl: 'homePage.html',
    controller: 'LoginController'
  })
    .state('registration', {
    url:'/reg',
    templateUrl:'templates/registration.html',
    controller:'UserDetailsController'
    });

  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise("/reg");

    });

havyakkaMaduve.controller("UserDetailsController",["$scope","$http",  function($scope,$http) {
  console.log("Inside userDetails Controller");
  $scope.submitDetails = function () {
    console.log("Submitting details");
    $http.get("/test").success(function(response){
      console.log("Test success");
    });
  };


}]);

Registration.html

<ion-pane>
  <ion-content class="padding">
    <div class="reg_list">
      <label class="item item-input">
        <span class="input-label">Full Name</span>
        <input type="text" required>
  </label>
  <label class="item item-input">
    <span class="input-label">Mane</span>
    <input type="text" required>
  </label>
  <label class="item item-input">
    <span class="input-label">Gotra</span>
    <input type="text" required>
  </label>
  <label class="item item-input">
    <span class="input-label">Date</span>
    <input type="date" required>
  </label>
  <label class="item item-input">
    <span class="input-label">Education</span>
    <input type="text" required>
  </label>
  <label class="item item-input">
    <span class="input-label">Occupation</span>
    <input type="text" required>
  </label>
  <label class="item item-input">
    <span class="input-label">Father's Name</span>
    <input type="text" required>
  </label>
  <label class="item item-input">
    <span class="input-label">Mother's Name</span>
    <input type="text" required>
  </label>
  <label class="item item-input">
    <span class="input-label">Current Location</span>
    <input type="text" required>
  </label>
  <label class="item item-input">
    <span class="input-label">Upload Image</span>
    <input type="file" required>
  </label>
  <label class="item item-input">
    <span class="input-label">Digital Identity</span>
    <input type="url" required>
  </label>
  <label class="item item-input">
    <span class="input-label">About Me</span>
    <input type="text">
  </label>
</div>
<button class="button button-block button-positive" onclick="submitDetails">Submit</button>
<div>
</div>

有人请告诉我我哪里出错了,因为我在这里没有看到任何问题,但我得到 "ReferenceError: submitDetails is not defined"。我在单击 "Submit" 按钮时看到问题 upon.Thanks。

你必须使用 ng-click 而不是 onclick,并且该函数应该用括号调用:

<button class="button button-block button-positive" ng-click="submitDetails()">Submit</button>