以下HTML无法按预期工作。即使我输入输入框,该按钮仍然处于禁用状态:
<form name="form">
<td>
<input type="text" ng-if="user.saveAllowed" ng-model="user.limit">
<p ng-if="!user.saveAllowed">{{user.limit}}</p>
</td>
<td ng-if="user.saveAllowed">
<button class="btn btn-limit btn-success" ng-click='user.setLimit(user.limit)' ng-disabled="form.$pristine">Save</button>
</td>
</form>
答案 0 :(得分:0)
当我尝试按预期工作时,你能查一下吗?
angular.module("myApp", []).controller("myCtrl", function($scope) {
$scope.user = {saveAllowed: true};
})
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<html ng-app="myApp">
<form name="form" ng-controller="myCtrl">
<td>
<input type="text" ng-if="user.saveAllowed" ng-model="user.limit">
<p ng-if="!user.saveAllowed">{{user.limit}}</p>
</td>
<td ng-if="user.saveAllowed">
<button class="btn btn-limit btn-success" ng-click='user.setLimit(user.limit)' ng-disabled="form.$pristine">Save</button>
</td>
</form>
</html>
&#13;