I want to iterate [object object] using *ngFor in Angular 2.
The problem is the object is not array of object but object of object which contains further objects.
{
"data": {
"id": 834,
"first_name": "GS",
"last_name": "Shahid",
"phone": "03215110224",
"role": null,
"email": "test@example.com",
"picture": **{ <-- I want to get thumb: url but not able to fetch that**
"url": null,
"thumb": {
"url": null
}
},
"address": "Nishtar Colony",
"city_id": 2,
"provider": "email",
"uid": "test@example.com"
}
}
I know we can use pipe to iterate the object but how we can iterate further from object to object means data->picture->thum:url.
If you are using a
map()
operator on your response,you could maybe chain atoArray()
operator to it...then you should be able to iterate through newly created array...at least that worked for me :)Angular now has a type of iterate Object for exactly this scenario, called a Set. It fit my needs when I found this question searching. You create the set, "add" to it like you'd "push" to an array, and drop it in an ngFor just like an array. No pipes or anything.
...
...