ng-model is undefined in controller

前端 未结 5 971
醉话见心
醉话见心 2020-12-10 03:56

I\'m using ionic and I have the following view:


  

        
5条回答
  •  北海茫月
    2020-12-10 04:26

    You need to define your $scope variables like this in your controller:

    $scope.membershipNo = '';
    $scope.password = '';
    

    So your controller would look like:

    app.controller('loginController', ['$scope', '$localstorage',
      function($scope, $localstorage) {
    
      $scope.membershipNo = '';
      $scope.password = '';
      $scope.login = function () {
        console.log("User logged in with membership no: " + $scope.membershipNo +
        "\n and password: " + $scope.password);
      }
    
    }]);
    

提交回复
热议问题