console.log() 不打印输出



我是Angular JS的新手,并尝试在浏览器控制台上打印用户名和电子邮件。我要么得到"未定义",要么它正在打印我给出的字符串。如何获得用户输入的电子邮件和用户名的输出?这是我的代码:

简介.html

<ion-view title="Profile" id="page2">
 <ion-content padding="true" class="has-header">
  <div ng-controller="profileCtrl"></div>
   <div id="profile-form1" class="list">
  <label class="item item-input">
    <input type="text" placeholder="Email"  ng-model="Email">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="Username" ng-model="Username">
  </label>
  <label class="item item-input" >
    <input type="password" placeholder="Password" ng-model="Password">
  </label>
  <ion-toggle toggle-class="toggle-balanced" id="profile-toggle1" ng-model="tc">Terms &amp; Conditions</ion-toggle>
</div>
<div ng-disabled=" (Email && Username && Password && tc) ? flase : true" ng-click="saveList()" style="border-radius:10px 10px 10px 10px;" class="button button-balanced  button-block">Login</div>
</ion-content>
</ion-view>

控制器.js

.controller('profileCtrl',  ['$scope', '$stateParams',
  function ($scope, $stateParams) {
    $scope.saveList = function(){
       console.log($scope.Email, $scope.Username);
    }
}])

控制台输出只是未定义未定义。

谢谢。

不要关闭div : <div ng-controller="profileCtrl"></div>

并且不要忘记关闭div标签:

 <ion-view title="Profile" id="page2">
 <ion-content padding="true" class="has-header">
     <div ng-controller="profileCtrl"> <!-- open it here -->
       <div id="profile-form1" class="list">
         <label class="item item-input">
           <input type="text" placeholder="Email"  ng-model="Email">
         </label>
         <label class="item item-input">
           <input type="text" placeholder="Username" ng-model="Username">
         </label>
         <label class="item item-input" >
            <input type="password" placeholder="Password" ng-model="Password">
         </label>
        <ion-toggle toggle-class="toggle-balanced" id="profile-toggle1" ng-model="tc">Terms &amp; Conditions</ion-toggle>
      </div>
      <div ng-disabled=" (Email && Username && Password && tc) ? flase : true" ng-click="saveList()" style="border-radius:10px 10px 10px 10px;" class="button button-balanced  button-block">Login</div>
    </div> <!-- close it here -->
</ion-content>
</ion-view>

最新更新