当索引等于长度时,我需要选择一个类。我有这个:
<ion-row *ngFor="let p of order.lines; let i = index" [ngClass]="order.lines.length == i? 'rowProductsf' : 'rowProducts'">
最佳答案
将条件更改为 [ngClass]="order.lines.length-1 == i
因为 index
从 0 开始,你也会错过拼写错误 ngClass
<ion-row *ngFor="let p of order.lines; let i = index" [ngClass]="order.lines.length-1 == i? 'rowProductsf' : 'rowProducts'">
关于javascript - Angular 选择类 if else,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61386465/