Christian Albaladejo
Christian Albaladejo

Reputation: 19

Angular select class if else

I need to select a class when the index is equal to the length. I have this:

<ion-row  *ngFor="let p of order.lines; let i = index" [ngClass]="order.lines.length == i? 'rowProductsf' : 'rowProducts'">

Upvotes: 0

Views: 35

Answers (1)

Hien Nguyen
Hien Nguyen

Reputation: 18973

Change your condition to [ngClass]="order.lines.length-1 == i because index start from 0, also you miss typo ngClass

<ion-row  *ngFor="let p of order.lines; let i = index" [ngClass]="order.lines.length-1 == i? 'rowProductsf' : 'rowProducts'">

Upvotes: 0

Related Questions