Reputation:
Is there a way to loop in *ngFor="let x of data[0]"
?
It gives me :
Cannot find a differ supporting object '[object Object]'
But if I do something like : *ngFor="let x of data" and print {{x.name}}
it works .
So the point is In data[0]
I have an element "el" that is another array.
So I want to do something like : let x of data[0].el
Upvotes: 0
Views: 53
Reputation: 2007
You can achieve this by using *ngFor
Your post will say this type of data
this.data=[{el:[{f:'fa1',l:'la1'},{f:'fa',l:'la'}],surename:'sarkar'}];
so in .html we need to change in *ngFor
*ngFor="let x of data[0]['el']
Upvotes: 1
Reputation: 1385
what about converting your assigning data[0] to an array?
in controller class level
newData: any[] = [];
in function
newData=data.json();
and then
*ngFor="let x of newData"
Upvotes: 1