我在ts文件中有一个json数组
"stocklist": {
"1": {
"product_name": "Chakli(500gm)",
"item_per_bag": "22",
"r_rate": "80",
"in_stock_qty": "129",
"current_requirement": 998,
"depreciateStock": -869,
"depreciateStockValue": -69520
},
"12": {
"product_name": "Khaman mix(200gm)",
"item_per_bag": "44",
"r_rate": "32",
"in_stock_qty": "301",
"current_requirement": 521,
"depreciateStock": -220,
"depreciateStockValue": -7040
}
}
我想在html文件中进行迭代。
<tr *ngFor="let deficit of deficitStockList;">
<td text-center>{{ deficit.id }}</td>
<td>{{ deficit.product_name }}</td>
<td>{{ deficit.in_stock_qty }}</td>
<td>{{ deficit.current_requirement }}</td>
<td>{{ deficit.depreciateStock }}</td>
</tr>
但它显示的错误就像数组不可迭代一样。
这里提到的密钥在Ionic中没用,但我无法从服务器端删除它。
谢谢,
答案 0 :(得分:0)
将数据格式对象更改为Object of Object,如下所述
"stocklist": [
{
"product_name": "Chakli(500gm)",
"item_per_bag": "22",
"r_rate": "80",
"in_stock_qty": "129",
"current_requirement": 998,
"depreciateStock": -869,
"depreciateStockValue": -69520
},
{
"product_name": "Khaman mix(200gm)",
"item_per_bag": "44",
"r_rate": "32",
"in_stock_qty": "301",
"current_requirement": 521,
"depreciateStock": -220,
"depreciateStockValue": -7040
}
]