Omprakash Sharma Omprakash Sharma - 1 year ago 94
AngularJS Question

pass index to ng-class with ng-repeat

I want to increment class sequence with

My requirement meets like

<div class="c1">image1</div>
<div class="c2">image2</div>
<div class="c3">image3</div>
<div class="cN">imageN</div>

I tried to reduce this as

<div ng-class="{'c':{{imgNo}}}" ng-repeat="imgNo in imgNos">Image{{imgNo}}</div>


<div ng-class="{'c[$index]':isTrue}" ng-repeat="imgNo in imgNos">Image{{imgNo}}</div>

Please help me with the correct way. Thanks

Answer Source

Try this

<div class="c{{imgNo}}" ng-repeat="imgNo in ImgNos">Image{{imgNo}}</div>


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download