Search code examples
cssangularjsng-class

AngularJS Multiple class using expression


I have a table where I need to apply two different classes, using expressions. 1st class is applied based on following expression. {'Up':'class-up', 'Down':'class-down'}[a.status] and 2nd class is applied based on bold: !a.read

The classes here are class-up, class-down, bold. So how should be the expression framed? I tried:

<tr ng-repeat="a in all" ng-class="{{'Up':'class-up', 'Down':'class-down'}[a.status],bold: !a.read}">

<tr ng-repeat="a in all" ng-class="{'Up':'class-up', 'Down':'class-down'}[a.status],bold: !a.read">

But I keep getting errors in console. What is the correct format to apply these classes based on the given expressions


Solution

  • With the clarification from your comment:

    <tr ng-repeat="a in all" ng-class="{'class-up': a.status=='up', 'class-down': a.status=='down', 'bold': !a.read}">hello world</tr>