在角度 ng 禁用中不起作用表达式



我是Angular的新手,所以也许我错过了一些东西。有谁知道,在这种情况下表达式状态有什么问题:

值"isDisable.state"在"p"标签中发生变化,但在"ng-disabled"中没有变化。该按钮不会将其状态更改为禁用。

这里是 plunk:http://plnkr.co/edit/zc8k9oCUxlMRCkZKjQa5?p=preview

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Example - example-example53-production</title>
  
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.1/angular.min.js"></script>
<script type="text/javascript">
var myapp = angular.module('switcher',[]);
myapp.controller('switchState', function ($scope) {
      $scope.isDisable = {'state':false};
      $scope.toggle = function () {
        $scope.isDisable.state = !$scope.isDisable.state;
       
      }
});
</script>
</head>
<body ng-app="switcher">
<div ng-controller="switchState">
<button ng-click="toggle()">toggle</button>
 <button ng-disabled="{{isDisable.state}}">Disabled</button>
 <p>{{isDisable.state}}</p>
</div>
</body>
</html>

删除{{}}

ng-disabled="isDisable.state"

最新更新