Tanasos
Tanasos

Reputation: 4098

Increment ngClass value

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

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

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

Related Questions