Angular 5 annot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Itera
By : user7878475
Date : March 29 2020, 07:55 AM
hope this fix your issue In your service, you are returning an object with only one property data, which is still an object, not an array. Try returning res.data: code :
getProducts(): Observable<Products[]> {
return this.http.get('http://localhost:8000/api/products')
.map(res => {
return res.data;
})
|
Angular 4 Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iter
By : Alexander Stashkevic
Date : March 29 2020, 07:55 AM
around this issue Try something like this where you create the object in your response component.ts code :
export class MatchComponent implements OnInit {
_postArrayMatch: match[];
newArr: Array<Object> = [];
constructor(public router:Router, private matchService: MatchService,
private route: ActivatedRoute) {}
ngOnInit(){
this.getMatchId();
}
getMatchId() :void {
this.route.params.forEach((params: Params)=> {
let id = +params['id'];
this.matchService.getMatch(id).subscribe(
resultArray => {
this._postArrayMatch = resultArray;
const keys = Object.keys(this._postArrayMatch) // new stuff starts here
for(let i = 0; i < keys.length; i++) {
newArr.push(this._postArrayMatch[keys[i]]);
newArr[i]['team'] = keys[i];
}
},
error => console.log("Error ::" + error))
})
}
<div *ngFor="let post of newArr">
<p> {{post.team}}: {{post.name}}</p>
</div>
|
Angular : Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iter
By : user3223903
Date : March 29 2020, 07:55 AM
wish help you to fix your issue This is because the response you get from the Weather API is an object an not an Array. Therefore it is not iterable. Updated code :
<button (click)="getWeather()">clcik me</button>
<h2 *ngFor="let data of Data | keyvalue">{{data.key}}: {{data.value}}</h2>
<button (click)="getWeather()">clcik me</button>
<h2>Current temperature: {{Data.main.temp}}</h2>
<h2>Wind speed: {{Data.wind.speed}}</h2>
|
Angular: "Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to
By : kh4ine12345612
Date : March 29 2020, 07:55 AM
it fixes the issue The problem is that you assign the result of the subscribe call to the teams property: code :
this.teams = this.playersService.fetchTeams(this.year).subscribe(...);
this.playersService.fetchTeams(this.year).subscribe(data => {
this.teams = data;
});
|
Error for Cast to ObjectId failed for value "[object Object],[object Object],[object Object]
By : facebook-10153560190
Date : March 29 2020, 07:55 AM
will be helpful for those in need I don't have a solution but I can try to explain what the problem is, or at least why it isn't working in your case. Although there's couple of solutions at the end that may or may not work.. Your provider.posts is an array of another set of documents referenced by "Posts", as defined in your Provider schema.
|