How to use $ index to change class in ng-repeat?
I have a list that is limited to three elements, the first element needs a class blue1
, the second one blue2
, the third one blue3
.
<ul>
<li ng-repeat="tag in chartTags" class="blue-tag">
<div class="tag blue1" ng-class="{blue1: tag == 1 }">{{tag.term}}</div>
</li>
<!-- <li><div class="tag blue1">item1</div></li>
<li><div class="tag blue2">item2</div></li>
<li><div class="tag blue3">item3</div></li> -->
</ul>
Is there a way to write a check like ng-class="{blue1: tag == 1 || blue2: tag == 2 || blue3: tag == 3 }"
+3
source to share
3 answers