在角度ng-disabled中不起作用

时间:2015-01-30 19:40:54

标签: javascript angularjs

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

值' isDisable.state'改变' p'标签,但不是“禁用”#。该按钮不会将其状态更改为禁用状态。

这是插件: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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:4)

删除{{}}

ng-disabled="isDisable.state"