Reputation: 4098
How to increment a class numeric value using ngClass
?
e.g. - <some-element [ngClass]="'class-*'">...</some-element>
, where *
should auto-increment until met conditions.
Upvotes: 1
Views: 736
Reputation: 658263
i:number = 0;
<some-element [ngClass]="'class-'+ i">...</some-element>
<button (click)="i = i+1">increment</button>
(I'm not sure if i++
work in a template)
Upvotes: 3