Aurick
Aurick

Reputation: 321

what is the best way to add ng-class with one complex condition

How can I integrate both ng-classes

ng-class="{removeBtn:'selected'}[resource.check_added_to_plan]" && ng-class="'lastSpan':($index+1)%3==0}"

If resource.check_added_to_plan is "removeBtn" then I need to add "selected" class

Thanks

Upvotes: 4

Views: 52

Answers (1)

Shomz
Shomz

Reputation: 37701

I'm really not sure, what are you trying to achieve, but you need to fix syntax errors and do something like this:

ng-class="{removeBtn: resource.check_added_to_plan, lastSpan: ($index+1)%3==0}"

So, in a form class1: condition1, class2: condition2, etc...

Upvotes: 2

Related Questions