I'm trying to have different classes based on the state, how's it possible to have different classes based on different conditions?
<i ng-class="'iconA': state == 100, 'iconB': state == 200, 'iconC': state == 300"></i>
I'm trying to have different classes based on the state, how's it possible to have different classes based on different conditions?
<i ng-class="'iconA': state == 100, 'iconB': state == 200, 'iconC': state == 300"></i>
I think you might just be missing some curly brackets just inside your double quotes - could you try this?
<i ng-class="{
'iconA': state == 100,
'iconB': state == 200,
'iconC': state == 300
}"></i>
We did something very similar recently which worked well for us:
<button class="date-picker__day" ng-class="{
'date-picker__day--this-month': ctrl.isActiveMonthForDay(day),
'is-selected': ctrl.isSelectedDay(day),
'is-active': ctrl.isActiveDay(day),
'is-today': ctrl.isToday(day),
'is-disabled': !ctrl.isDateAllowed(day),
}"></button>
From the Angular docs for ngClass:
The result of the evaluation can be a string representing space delimited class names, an array, or a map of class names to boolean values. In the case of a map, the names of the properties whose values are truthy will be added as css classes to the element.
What you already have is close to a map. You just need to wrap it in braces.
<i ng-class="{'iconA': state == 100, 'iconB': state == 200, 'iconC': state == 300}"></i>