簡體   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

大家好,我有這個錯誤錯誤錯誤:找不到支持“對象”類型的 object“[對象對象]”的不同。 NgFor 只支持綁定到 Iterables

我試過了。json 但它在 angular 9 中不起作用

我的組件.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>

我的組件.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];

我的 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"
        }];

我想你正在嘗試做這樣的事情:

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

這個問題在這里也得到了很好的回答:

在 Angular 中迭代 object

如何在 Angular 中使用 ngFor 循環 object 屬性

如果您使用*ngFor ,它只支持數據類型為array or iterables

在您的變量dropDownList中的場景數據是 object 類型或可能是 null | 不明確的。 因此發生此錯誤。 在使用該數據之前對其進行控制台。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 角度錯誤:找不到“object”類型的不同支持對象“[object Object]”。 NgFor 僅支持綁定到 Iterables,例如 Arrays 角度4:找不到類型為“對象”的其他支持對象“ [對象對象]”。 NgFor僅支持綁定到可迭代對象,例如數組 Angular:“找不到類型為‘object’的不同支持對象‘[object Object]’。 NgFor 僅支持綁定到 Iterables,例如 Arrays' 找不到類型為“對象”的其他支持對象“ [對象對象]”。 NgFor僅支持綁定到可迭代對象,例如數組 離子2:找不到類型為“對象”的其他支持對象“ [對象對象]”。 NgFor僅支持綁定到可迭代對象,例如數組 Angular2找不到類型為“字符串”的其他支持對象。 NgFor僅支持綁定到可迭代對象,例如數組 Angular 問題:找不到支持“object”類型的 object“[object Object]”的不同。 NgFor 僅支持綁定到諸如 Arrays 之類的 Iterables 找不到支持 object 類型為“object”的“[object Object]”的差異。 NgFor 僅支持綁定到 Iterables,例如 Array。 json 數據 找不到不同的支持 object '[object Object]'。 NgFor 僅支持綁定到諸如 Arrays 之類的 Iterables 我不斷收到此錯誤:找不到不同的支持 object '[object Object]' 類型為 'object'。 NgFor 只支持
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM