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
{'Up':'class-up', 'Down':'class-down'}[a.status]
. Herea.status
returnsUp
orDown
as response which in turns appliesclass-up
andclass-down
classes respectively. – Aniket Sinha Jul 4 at 10:30ng-class="{ 'class-up': a.status === 'Up', 'class-down': a.status === 'Down', 'bold': !item.read }"
– Paolo Moretti Jul 4 at 10:34