简体   繁体   English

找不到支持 object 类型为“object”的“[object Object]”的差异。 NgFor 仅支持绑定到 Iterables,例如 Array。 json 数据

[英]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']">
  1. 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.首先确保您的数据格式正确。

  2. 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.

相关问题 错误:找不到类型为“对象”的其他支持对象“ [对象对象]”。 NgFor仅支持绑定到Iterables - Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables Angular 7 找不到类型为“object”的不同支持对象“[object Object]”。 NgFor 只支持绑定到 Iterables,比如 Arrays - Angular 7 Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays 错误找不到类型为“对象”的其他支持对象“ [对象对象]”。 NgFor仅支持绑定到可迭代对象,例如数组 - ERROR Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays Angular 9 找不到支持“对象”类型的 object“[对象对象]”的不同。 NgFor 仅支持绑定到诸如 Arrays 之类的 Iterables - Angular 9 Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays 找不到类型为“object”的不同支持对象“[object Object]”。 NgFor 仅支持绑定到可迭代对象,例如数组。 [Angular 8] - Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.[Angular 8] 找不到“object”类型的不同支持对象“[object Object]”。 NgFor 仅支持绑定到 Iterables,例如 Arrays。 ? 怎么解决? - Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays. ? How solve it? 错误:“对象”类型的“[对象对象]”。 NgFor 仅支持绑定到 Iterables,例如 Arrays。 - 离子项目 - Error: '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays. - Ionic Project 在角度6中找不到类型为“对象”的其他支持对象“ [对象对象]” - Cannot find a differ supporting object '[object Object]' of type 'object' in angular 6 错误:找不到支持 object '[object Object]' 类型 'object' 的差异 - Err: Cannot find a differ supporting object '[object Object]' of type 'object' 迭代数组中的数组时出错:“找不到支持 object '[object Object]' 类型为 'object' 的不同。” - Error when iterating over array within array: “Cannot find a differ supporting object '[object Object]' of type 'object'.”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM