JSON data
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'. NgFor only supports binding to Iterables such as Arrays.the below is 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);
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"]
. It should be an 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.
assets:[[tool_order_id: "38",order_status_id: "10"]],
assets:[tool_order_id: "1",order_status_id: "10"],
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.