Ionic $scope中没有form对象
在ionic中 form需要定义在<ion-content>外面,否则在$scope中找不到form对象。
<ion-view >
<form name="loginForm" role="form">
<ion-content class="has-header has-footer">
<div class="list">
<div class="item item-borderless">
</div>
<div class="item item-input">
<label ng-class="{'has-error':loginForm.$submitted&&loginForm.userName.$invalid}">
<input type="text" name="userName" placeholder="姓名" ng-required>
</label>
</div>
<div class="item">
</div>
<div class="item item-borderless">
<button class="button button-block button-calm" ng-click="enter()">进入</button>
</div>
</div>
</ion-content>
</form>
</ion-view>
<form name="loginForm" role="form">
<ion-content class="has-header has-footer">
<div class="list">
<div class="item item-borderless">
</div>
<div class="item item-input">
<label ng-class="{'has-error':loginForm.$submitted&&loginForm.userName.$invalid}">
<input type="text" name="userName" placeholder="姓名" ng-required>
</label>
</div>
<div class="item">
</div>
<div class="item item-borderless">
<button class="button button-block button-calm" ng-click="enter()">进入</button>
</div>
</div>
</ion-content>
</form>
</ion-view>