I have a controller that returns a JSON object in the following format:
[
{"idCliente":1,
"nomeFantasia":"Flores",
"razaoSocial":"Transportes Flores Ltda.",
"contatosClientes":
[ {"idContatoCliente":1,
"dddCelular":21,
"email":"[email protected]"},
{"idContatoCliente":2,
"dddCelular":21,
"email":"[email protected]"}
]
}
]
And I have a template that tries to format the data above as follows:
<tr ng-repeat="cliente in clientes | filter:searchText">
<td>{{cliente.idCliente}}</td>
<td>{{cliente.razaoSocial}}</td>
<td>{{cliente.nomeFantasia}}</td>
<td>{{cliente.contatosClientes.email}}</td>
<td>
<div class="right floated ui green icon buttons">
<div class="ui button">Editar</i></div>
</div>
</td>
</tr>
The problem is that the highest keys ( idCliente
, razaoSocial
, etc) I can access with the objeto.chave
syntax, but the keys in nested arrays ( contatosClientes
) I can not access it in the same way ( cliente.contatosClientes.email
).
I've tried everything and I'm even thinking about changing my API, but does anyone know how to do this in AngularJS?