简体   繁体   English

错误 错误:找不到支持“对象”类型的 object“[对象对象]”的不同。 NgFor 仅支持绑定到 Iterables Angular 9

[英]ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables Angular 9

hello every one i have this error ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'.大家好,我有这个错误错误错误:找不到支持“对象”类型的 object“[对象对象]”的不同。 NgFor only supports binding to Iterables NgFor 只支持绑定到 Iterables

i tried.json but it s not working in angular 9我试过了。json 但它在 angular 9 中不起作用

My component.html我的组件.html

  <div class="form-group">
                <label for="">Ville</label>
                <select class="form-control" #hh
                    (change)="getidregion(hh.value)">
                    <option></option>
                    <option *ngFor="let ville of dropDownList"
                        [value]="ville.id">
                        {{ville.nomVille}}
                    </option>

                </select>

            </div>

My Component.TS:我的组件.TS:

dropDownList: [];

  responsable = {

    id: 0,
    nomResponsable: '',
    prenomResponsable: '',
    emailResponsable: '',
    mdpResponsable: '',
    img: '',
    rib: '',
    dtn: '',
    region: 0,
    ville: 0,
  };

    methodAPIToGetVilles() {
        this.res.getville()
          .subscribe((s: any) => {
            this.dropDownList = s;
    
          });
      }
    
      //methode to get the value off the idville in the option
      getidville(id: any): void {
        this.responsable.ville = id;
    
      }
    
      curUser: any = this.responsable[0];

My API Data:我的 API 数据:

"@context": "/api/contexts/Ville",
    "@id": "/api/villes",
    "@type": "hydra:Collection",
    "hydra:member": [
        {
            "@id": "/api/villes/6",
            "@type": "Ville",
            "nomVille": "Davidboeuf"
        },
        {
            "@id": "/api/villes/7",
            "@type": "Ville",
            "nomVille": "Benoitboeuf"
        }];

I suppose you are trying to do something like this:我想你正在尝试做这样的事情:

<div *ngFor="let item of object | keyvalue">
  {{item.key}}:{{item.value}}
</div>

This questions is also answered pretty nicely here:这个问题在这里也得到了很好的回答:

Iterate over object in Angular 在 Angular 中迭代 object

How to loop over object properties with ngFor in Angular 如何在 Angular 中使用 ngFor 循环 object 属性

If you are using *ngFor , it only supports data is of type array or iterables only.如果您使用*ngFor ,它只支持数据类型为array or iterables

In your scenario data in your variable dropDownList is either of type object or may be null |在您的变量dropDownList中的场景数据是 object 类型或可能是 null | undefined.不明确的。 Hence this error occur.因此发生此错误。 Console that data before using it.在使用该数据之前对其进行控制台。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 角度错误:找不到“object”类型的不同支持对象“[object Object]”。 NgFor 仅支持绑定到 Iterables,例如 Arrays - Angular error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays 角度4:找不到类型为“对象”的其他支持对象“ [对象对象]”。 NgFor仅支持绑定到可迭代对象,例如数组 - Angular 4 : Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays Angular:“找不到类型为‘object’的不同支持对象‘[object Object]’。 NgFor 仅支持绑定到 Iterables,例如 Arrays' - Angular: 'Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays' 找不到类型为“对象”的其他支持对象“ [对象对象]”。 NgFor仅支持绑定到可迭代对象,例如数组 - Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays 离子2:找不到类型为“对象”的其他支持对象“ [对象对象]”。 NgFor仅支持绑定到可迭代对象,例如数组 - Ionic 2: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays Angular2找不到类型为“字符串”的其他支持对象。 NgFor仅支持绑定到可迭代对象,例如数组 - Angular2 Cannot find a differ supporting object of type 'string'. NgFor only supports binding to Iterables such as Arrays Angular 问题:找不到支持“object”类型的 object“[object Object]”的不同。 NgFor 仅支持绑定到诸如 Arrays 之类的 Iterables - Angular problem: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays 找不到支持 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 找不到不同的支持 object '[object Object]'。 NgFor 仅支持绑定到诸如 Arrays 之类的 Iterables - Cannot find a differ supporting object '[object Object]'. NgFor only supports binding to Iterables such as Arrays 我不断收到此错误:找不到不同的支持 object '[object Object]' 类型为 'object'。 NgFor 只支持 - I keep getting this ERROR: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM