【发布时间】:2021-10-21 10:04:26
【问题描述】:
我有 2 个 *ngFor,每个都有 2 个索引。
<ng-container *ngFor="let groupItems of item.itemsList | groupBy: 'category'; index as i">
<div class="field-view">
<div class="label-view">
{{ groupItems.groupName }}
</div>
</div>
<ng-container *ngFor="let item of groupItems.items; index as j">
<div class="field-view" [itemValue]="item.total">
<div class="value-view">
{{ item.total }}
</div>
</div>
</ng-container>
</ng-container>
我想把i和j的总索引
我尝试使用[itemValue]="item.total[i][j]" 和{{ item.total[i][j] }}
但显示错误No index signature with a parameter of type 'number' was found on type 'Number'.
你能告诉我任何想法吗?
我有这个乔恩:
[
{
"id":3,
"itemsList": [
{
"total": 20000,
"itemId": "123",
"category": "test"
}
]
},
{
"id":2,
"itemsList": [
{
"total": 2000,
"itemId": "235",
"category": "test1"
}
]
},
{
"id":1,
"itemsList": [
{
"total": 200,
"itemId": "5452",
"category": "test"
}
]
}
]
【问题讨论】:
-
能分享一下item.itemsList的值吗?
-
是的,我分享它。谢谢
-
您有对象 item.itemList 或 itemValue 的类型定义吗?可以分享一下吗?
标签: angular typescript indexing ngfor