JSON数据
data:[
{
assets:[[tool_order_id: "38",order_status_id: "10"]],
order_info:[id: "1", order_type: "6",check: "1", current_Stage_id: "29"]
},
{
assets:[tool_order_id: "1",order_status_id: "10"],
order_info:[id: "2", order_type: "3",check: "1", current_Stage_id: "29"]
},
{
assets:[[tool_order_id: "8",order_status_id: "10"]],
order_info:[id: "3", order_type: "3",check: "1", current_Stage_id: "29"]
},
{
assets:[tool_order_id: "3",order_status_id: "10"],
order_info:[id: "4", order_type: "3",check: "1", current_Stage_id: "29"]
}
]
如果我重复这个,我就会出错。找不到类型为"object"的不同支持对象"[object object]"。NgFor只支持绑定到Arrays等Iterables。下面是html
<div *ngIf="orders['assets'].length != 0">
<ion-row *ngFor="let tool of orders['assets']">
<ion-col col-4>{{ tool.tool_order_id }}</ion-col>
<ion-col col-4>{{ tool.order_status_id }}</ion-col>
</ion-row>
<div *ngIf="orders['assets'].length != 0">
<ion-row *ngFor="let tool of orders['assets']['0']">
<ion-col col-4>{{ tool.tool_order_id }}</ion-col>
<ion-col col-4>{{ tool.order_status_id }}</ion-col>
</ion-row>
在data.ts文件中按顺序存储数据this.orders = this.data; console.log(this.orders);
能够在控制台中显示数据。
如果它以某种方式进入控制台,您可以在循环中进行循环
<div ngbDropdownMenu aria-labelledby="dropdownMenuButton2" *ngFor="let pChannel of channels">
<div *ngFor="let channel of pChannel">
<a class="dropdown-item" (click)="getVouchersByChannelId(channel.channelId)">
{{ channel.channelName }}
</a>
</div>
</div>
试试这样的
<ion-row *ngFor="let t of data">
<ion-row *ngFor="let tool of t.orders['assets']">
-
数据格式不正确。[]表示数组。在数组中,不能直接使用键值对
[tool_order_id: "38",order_status_id: "10"]
。它应该是一个对象{tool_order_id: "38",order_status_id: "10"}
。首先要确保您的数据格式正确。 -
请消除数据中的不一致,比如第1行中的资产是数组,第2行中的是数组。
资产:[[tool_order_id:"38",order_status_id:"10"]],
资产:[tool_order_id:"1",order_status_id:"10"],