hello i am trying to use several expression in my ng-class
directive but i keep getting this error in my browser console:
Error: [$parse:syntax] Syntax Error: Token '==' is unexpected, expecting [:] at column 13 of the expression [{ isWorking == true }] starting at [== true }].
This is my code:
ng-class="{ 'btn-danger': isReady == true || isError == true, 'btn-warning': isWorking == true, 'btn-success': isSuccess == true }"
Could someone please tell me what i am doing wrong here?
No need to explicitly check for true
. Observe the following...
ng-class="{ 'btn-danger': isReady || isError, 'btn-warning': isWorking, 'btn-success': isSuccess }"
JSFiddle Link - simple demo
Also check out The Many Ways To Use ngClass - this blog post is very helpful for doing anything with ng-class
, I highly recommend giving it a look.