Reputation: 12716
I'm trying to disable a button from a controller when a directive emits a ready status.
I'm passing in a boolean to ng-disabled
:
<button ng-disabled="{{pointsClaimed}}" ng-click="playVideo()">{{buttonText}}</button>
My controller:
$scope.buttonText = 'Watch Video to Claim Points';
$scope.pointsClaimed = false;
$scope.$on('pointsClaimed', function(){
$scope.buttonText = 'Points Claimed!';
$scope.pointsClaimed = true;
});
I can see that the button is changing from false to true:
But the actual button isn't being disabled.
If I hardcode in true or false, it works as expected. If the value is changing as expected in the HTML, why isn't the button being disabled?
Upvotes: 0
Views: 1058
Reputation: 4862
Don't think you need the curly brackets. Try..
<button ng-disabled="pointsClaimed" ng-click="playVideo()">{{buttonText}}</button>
Also a good demo in the docs.
Upvotes: 5