Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting button disabled to result of string compare in angularjs

Right now I have:

<button ng-click="doSomething()" ng-disabled="{{aVariable}} != 'Ready'">Button 1</button>

Where aVariable is initially set to 'Ready' and subsequently set to an integer then back to Ready.

But the button won't disable/enable based on the input.

like image 716
Bryce Langlotz Avatar asked Mar 16 '23 20:03

Bryce Langlotz


1 Answers

ng-disabled doesn't required interpolation directive {{}}, you can directly use angular scope variables inside directive for solving expressions

Markup

<button ng-click="doSomething()" ng-disabled="aVariable != 'Ready'">Button 1</button>

Hope this could help you, Thanks.

like image 138
Pankaj Parkar Avatar answered Apr 13 '23 00:04

Pankaj Parkar