angularjsangularjs-ng-disabled

Using ng-disabled button is still disabled even if value in condition changes


I have a button:

<button ng-disabled="ctrl.myService.getData().someProperty ? '' : 'disabled'">
  Click me!
</button>

When the application loads someProperty does not exist on ctrl.myService.getData(). So the button is disabled.

But after a few seconds someProperty is set on ctrl.myService.getData() but my button is still disabled .. any idea why its not enabling the button based on the new property?


Solution

  • Also be sure to call $scope.apply() at the end of your methods execution so it can apply the changes necessary