[英]Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Array. json data
JSON data 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"]
}
]
if I iterate this I am getting error.如果我重复这个,我会收到错误。 Cannot find a differ supporting object '[object Object]' of type 'object'.
找不到支持 object 类型为“object”的“[object Object]”的差异。 NgFor only supports binding to Iterables such as Arrays.the below is html
NgFor 只支持绑定到 Iterables 比如 Arrays 下面是 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>
and in data.ts file store the data in orders this.orders = this.data; console.log(this.orders);
并在 data.ts 文件中按顺序存储数据
this.orders = this.data; console.log(this.orders);
this.orders = this.data; console.log(this.orders);
able to display the data in console.能够在控制台中显示数据。
You can do loop inside loop if it coming in console somehow如果它以某种方式进入控制台,你可以在循环内循环
<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>
Try something like this尝试这样的事情
<ion-row *ngFor="let t of data">
<ion-row *ngFor="let tool of t.orders['assets']">
The data is not in properly formatted.数据格式不正确。 [ ] denotes an array.
[ ] 表示一个数组。 Inside an array you can't have key value pairs directly,
[tool_order_id: "38",order_status_id: "10"]
.在数组中,您不能直接拥有键值对
[tool_order_id: "38",order_status_id: "10"]
。 It should be an object {tool_order_id: "38",order_status_id: "10"}
.它应该是一个 object
{tool_order_id: "38",order_status_id: "10"}
。 First make sure your data is properly formatted.首先确保您的数据格式正确。
Please get rid of inconsistencies in the data like assets in line 1 is an array of arrays and in line 2 it is an array.请消除数据中的不一致,例如第 1 行中的资产是 arrays 的数组,而第 2 行中它是一个数组。
assets:[[tool_order_id: "38",order_status_id: "10"]],资产:[[tool_order_id: "38",order_status_id: "10"]],
assets:[tool_order_id: "1",order_status_id: "10"],资产:[tool_order_id:“1”,order_status_id:“10”],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.