Reputation: 2608
I would like to disable a button if the localStorage variable 'compute' doesn't exist, and enable it when it exists (the app can create or destroy this variable a few times). Thanks
<button nav-direction="back" class="button yy" ui-sref="app.result" ui-sref-active="currentNav" ng-disabled="{{bool}}" ng-click="navResult()">
Board
</button>
Upvotes: 0
Views: 664
Reputation: 54771
ngDisabled takes an expression as it's argument. You are binding a value by using {{bool}}
when it should be just bool
<button nav-direction="back" class="button yy" ui-sref="app.result" ui-sref-active="currentNav" ng-disabled="bool" ng-click="navResult()">
Board
</button>
Upvotes: 1
Reputation: 11576
Use ng-enabled as follows.
<button ng-enabled="localStorage.getItem('compute') === null" nav-direction="back" class="button yy" ui-sref="app.result" ui-sref-active="currentNav" ng-click="navResult()">
Board
</button>
You can also use angular-local-storage https://github.com/grevory/angular-local-storage
Upvotes: 1