angular ng-disable 没有按预期工作
angular ng-disable not working as expected
我正在尝试在指令发出就绪状态时从控制器禁用按钮。
我正在将一个布尔值传递给 ng-disabled
:
<button ng-disabled="{{pointsClaimed}}" ng-click="playVideo()">{{buttonText}}</button>
我的控制器:
$scope.buttonText = 'Watch Video to Claim Points';
$scope.pointsClaimed = false;
$scope.$on('pointsClaimed', function(){
$scope.buttonText = 'Points Claimed!';
$scope.pointsClaimed = true;
});
我可以看到按钮正在从 false 变为 true:
但实际按钮并未被禁用。
如果我硬编码为 true 或 false,它会按预期工作。如果 HTML 中的值按预期变化,为什么按钮没有被禁用?
我正在尝试在指令发出就绪状态时从控制器禁用按钮。
我正在将一个布尔值传递给 ng-disabled
:
<button ng-disabled="{{pointsClaimed}}" ng-click="playVideo()">{{buttonText}}</button>
我的控制器:
$scope.buttonText = 'Watch Video to Claim Points';
$scope.pointsClaimed = false;
$scope.$on('pointsClaimed', function(){
$scope.buttonText = 'Points Claimed!';
$scope.pointsClaimed = true;
});
我可以看到按钮正在从 false 变为 true:
但实际按钮并未被禁用。
如果我硬编码为 true 或 false,它会按预期工作。如果 HTML 中的值按预期变化,为什么按钮没有被禁用?