<ion-view cache-view="false">
<ion-content class="has-header has-smallsubheader" >
<form name="$root.deliveryDetails" action="#">
<div>
<div class="paddingOnSides">
<p><input type="number" name="usermobileNumber" ng-model="userEnteredMobileNumber" /> </p>
<div>
<span class="button" ng-click="checkRegisteredUsers()">Verify</span>
</div>
</div>
</ion-view>
</ion-content>
控制器:
$scope.checkRegisteredUsers = function(){
console.log($scope.userEnteredMobileNumber) //gives undefined
}
我尝试在ng-model
字段formData.userEnteredMobileNumber
中使用对象而不是原语,但我仍然未定义。
我该如何解决这个问题?
答案 0 :(得分:0)
使用相同的代码创建了一个样本plunkr并且工作正常。
<body ng-controller="MainCtrl">
<form name="$root.deliveryDetails" action="#">
<div>
<div class="paddingOnSides">
<p><input type="number" name="usermobileNumber" ng-model="userEnteredMobileNumber" /></p>
<div>
<span class="button" ng-click="checkRegisteredUsers()">Verify</span>
</div>
</div>
<p>Mobile {{userEnteredMobileNumber}}!</p>
</div>
</form>
</body>