简体   繁体   English

错误 错误:找不到支持“对象”类型的 object“[对象对象]”的不同。 得到这个得到 API

[英]ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. Getting this in get API

This Error is coming when I am trying to show the data from an get api on html template using ngfor in angular当我尝试使用 angular 中的 ngfor 在 html 模板上显示来自 get api 的数据时,出现此错误

ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'.错误 错误:找不到支持“对象”类型的 object“[对象对象]”的不同。 NgFor only supports binding to Iterables such as Arrays. NgFor 仅支持绑定到 Iterables,例如 Arrays。

This is my bankComponent.ts file这是我的 bankComponent.ts 文件

 
  getSearchBankAPI(postData : Create , postForm : NgForm){
    this._newApiService.getSearchBank(
      postData.address,
       postData.bankId,
      postData.bankName,
      postData.branch,
      postData.ifscCode,
       postData.passBookNo
      
      )
     
   console.log("Search Customer API Called!!");
   postForm.reset();
  
  localStorage.setItem("bankIFSCvalue",this.bankvalue);
  console.log(localStorage.getItem("bankIFSCvalue"))

   this.getBankById();
    }


    public getBankById(){
  return this.http.get('http://localhost:9900/api/v1/bank/' + localStorage.getItem("BankId"))
  .subscribe((responseData)=>
  {
    
     this.response = JSON.parse(JSON.stringify(responseData));
    console.log("Bank name is :" + this.response.body.bankName)
    console.log(this.response)
    
    
    });  
      }
    }

Here I am calling the getBankById() get API from getSearchBankAPI() method and I want to display the result of getBankId() get API on the template.这里我调用 getBankById() get API from getSearchBankAPI() 方法,我想在模板上显示 getBankId() get API 的结果。

This is my template code这是我的模板代码

                            <thead>
                            <tr>
                              <th scope="col">Bank Name</th>
                              <th scope="col">Branch</th>
                              <th scope="col">IFSCCode</th>
                            </tr>
                            <tr *ngFor="let e of response">
                                <th scope="col">{{e.bankName}}</th>
                                <th scope="col">{{e.branch}}</th>
                                <th scope="col">{{e.ifscCode}}</th>
                            </tr>
                            
                            </thead>
                        
                          </table>




Is the answer to use...答案是用...

<tr *ngFor="let e of response.body">

instead of代替

<tr *ngFor="let e of response">

? ?

暂无
暂无

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

相关问题 我不断收到此错误:找不到不同的支持 object '[object Object]' 类型为 'object'。 NgFor 只支持 - I keep getting this ERROR: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports Angular 6错误:找不到类型为“字符串”的其他支持对象 - Angular 6 Error: Cannot find a differ supporting object of type 'string' 找不到&#39;对象&#39;类型的不同支持对象&#39;[object Object]&#39; - Cannot find a differ supporting object '[object Object]' of type 'object' 错误:找不到类型为“ ...”的其他支持对象“ [object Object]”。 NgFor仅支持……} - Error: Cannot find a differ supporting object '[object Object]' of type '…'. NgFor only supports……} 错误 错误:找不到支持“对象”类型的 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”类型的不同支持对象“[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 NG02200:找不到“对象”类型的不同支持对象“[对象对象]” - NG02200: Cannot find a differ supporting object '[object Object]' of type 'object' 角度4:找不到类型为“对象”的其他支持对象“ [对象对象]”。 NgFor仅支持绑定到可迭代对象,例如数组 - Angular 4 : 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
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM