hariszaman
hariszaman

Reputation: 8424

Apply class conditionally angular

I am trying to apply class conditionally through ng-class but its not working

ng-class="{'margin-watch':progress <= '0','margin-continue-watch':progress > '0' }"

Upvotes: 0

Views: 82

Answers (2)

Guinn
Guinn

Reputation: 1385

Unless your condition requires you to compare progress to the character '0', you should remove the quotes around the 0. That should fix your expressions! For readability I suggest you apply the () as Yasser does in his answer, but it should work without aswell.

Upvotes: 1

Yasser Shaikh
Yasser Shaikh

Reputation: 47774

Try this

ng-class="{'margin-watch': (progress <= 0), 'margin-continue-watch': (progress > 0) }

Upvotes: 1

Related Questions