i have the following JSON with nested elements
[
{
"firstName": "John",
"lastName": "Smith",
"gender": "m",
"places": [{
"name": "London",
"contacts": [{
"type": "phone",
"value": "123456789"
},{
"type": "email",
"value": "[email protected]"
}]
}, {
"name": "Paris",
"contact": [{
"type": "phone",
"value": "987654321"
}]
}]
},
{
"firstName": "Jane",
"lastName": "Doe",
"gender": "f",
"places": [{
"name": "Paris",
"contacts": [{
"type": "email",
"value": "[email protected]"
}]
}]
}
]
and i'm trying to display it in HTML table with AngularJS and ng-repeat as follows:
Name Places Email Telephone --------------------------------------------------------- Jonh Smith London [email protected] 123456789 Paris 987654321 Jane Doe Paris [email protected]
Is there a nice way to do it (in one stroke - without too many nested loops) or should I really loop contacts over and over in each "td"-element?
EDIT: I'm looking for an answer like this one here, the only "solution" (if i even can call it that) i came up with is to iterate locations in each "table data"-element over and over, so if each person has 3 locations with 4 phone/emails there will be like 12 iterations per cell or 48 iterations per person (row). Is there really no smart way to do it in ng-repeat or should i just give up with table layout by nested JSON?