javascript - Angular 选择类 if else

标签 javascript angular ionic-framework

当索引等于长度时,我需要选择一个类。我有这个:

<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/

相关文章:

angular - 如何在 Angular Material List 中使用 Item 组件

angular - 使用 angular 8 和 webpack 添加 Assets 图像

cordova - 由于与 google gms 服务版本冲突,FCMPlugin 构建失败

html - 聊天框固定在最大宽度时不会扩展 <p>

javascript - 在 JavaScript 中调用赋值函数

javascript - 将 JS Regex 捕获组存储在数组中的最佳方式?

javascript - 如何在包含 HTML 的变量中绑定(bind) blob?

ios - ionic 2 iOS,无法服务,卡在复制完成

php - angularJS $http.get() 对复杂 JSON 输出的请求

javascript - 为 react/react-intl 动态导入语言 json 文件