I'm trying to set up an ng-class to work on a div with two conditions:
ng-class="(accounts.length == 1 && account.cardName =='Cash') ? 'one-dash-cash' : ''"
and
ng-class="(accounts.length == 1 && account.cardName =='Points') ? 'one-dash' : ''"
What's the best way to accomplish this? I've read that I shouldn't have all this logic in the HTML, but I'm not sure how to do this.
Thanks in advance..
The answers provided by Shankar and user3227295 are correct and work correctly, but there are 2 alternate methods that you can use. I am not saying that they are better than the ones already mentioned, but it is better to be aware of them. Here is a plunker showing all three approaches.
Put your logic in controller than inline (which I would use)
And in your html
Use an attribute directive. This may be an overkill for your case, but surely a way.