[英]Cannot find a differ supporting object '[object Object]
I know this question has been asked before, but please read this completely before you FLAG me... I have tried what the other posts have said, but I cannot stop the error.
我知道之前曾问过这个问题,但是请在阅读之前完全读完我……我已经尝试了其他帖子所说的内容,但是我无法阻止该错误。
Question: I am getting this cursed error,
问题:我遇到了这个被诅咒的错误,
"Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays." “找不到类型为'object'的其他支持对象'[object Object]'。NgFor仅支持绑定到Iterables,例如数组。”
and I don't understand what I am doing wrong, so WHAT AM I DOING WRONG? 而且我不明白自己在做什么错,那我在做什么错呢?
Explanation: I am reaching out to saleforce to retrieve an array of over 1400+ responses.
说明:我正在与salesforce联络,以检索超过1400多个响应的数组。 I have been working with Angular long enough to know how to put the code together, but don't fully understand it.
我已经与Angular一起工作了很长时间,知道如何将代码组合在一起,但是并没有完全理解它。 This is the same approach I am using for other request I have sent to salesforce.
这与我发送给Salesforce的其他请求所使用的方法相同。
My Attempts: So the first SO post I read ( Angular: Cannot find a differ supporting object '[object Object]' ) spoke about the format of the array.
我的尝试:因此,我阅读的第一篇SO帖子( Angular:找不到其他支持对象'[object Object]' )谈到了数组的格式。 The array is coming back in the same format as others (which have no error), and I have tried to even format the response into .json() to be sure.
数组以与其他数组相同的格式返回(没有错误),为了确保响应,我甚至尝试将响应格式化为.json()。 The second post ( Cannot find a differ supporting object '[object Object]' ) said something about using similar names, but I don't believe that applies to me.. and regardless they didn't solve my issue.
第二篇文章( 找不到另一个支持对象'[object Object]' )说了一些有关使用相似名称的内容,但是我不认为这适用于我..并且不管它们没有解决我的问题。
THE CODE:
编码:
This reaches out the a service that reaches to the salesforce API 这提供了到达salesforce API的服务
getProviders(){ this.reqObj.email = this.cus.getCurrentUser(); this.dss.allProviders(this.reqObj).subscribe(res => { this.serviceProvider = res console.log("All Providers", res); }) } //End getProviders
How I link to the API 我如何链接到API
allProviders(reqObj): Observable<Object>{ return this.http.get("https://xxxxxx.execute-api.us-east- .amazonaws.com/prod").map(res => res); }
iteration in the HTML HTML中的迭代
<div class="table-row n-txt" *ngFor="let sList of serviceProvider; let i=index" (click)="openProviderAction(sList)"> <div class="table-cell c1">{{sList.Name}}</div> <div class="table-cell c2" > -- -- </div> <div class="table-cell c2" > {{sList.county__c}} </div> <div class="table-cell c3" > {{sList.Phone}}</div> <div class="table-cell c4" >
Is it possible that the size of the array is causing the error??? 数组的大小是否可能导致错误?
I really hope everyone can empathize with me here. 我真的希望每个人都能在这里同情我。 Not sure how i was so careless and didn't think to look, but i declared the object serviceProvider likes so => serviceProvider: any = {} ... This was a simple fix, to serviceProvider: any = [];
不知道我怎么这么粗心,也没想看,但是我宣布对象serviceProvider喜欢这样=> serviceProvider:any = {} ...这是对serviceProvider的简单修复:any = []; Thank you guys regardless, i appreciate the information and outside eyes.
谢谢大家,我非常感谢您提供的信息和帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.