0
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 higher keys (idCliente
, razaoSocial
, etc) I can access with the syntax objeto.chave
, but the keys to us arrays nested (contatosClientes
) I can’t access it the same way (cliente.contatosClientes.email
).
I’ve tried everything and I’m even thinking about changing my API, but someone knows how to do it in Angularjs ?
Wendel, I changed here as you suggested but it didn’t work.
– Antonio Belloni
@Antoniobelloni Wendel’s example above lacked only one detail to work. Instead of
<td ng-repeat="contato in cliente>{{contato.email}}</td>
utilize<td ng-repeat="contato in cliente.contatosClientes>{{contato.email}}</td>
– Thiago Dorneles
@Thank you Thiagodorneles, I hadn’t even noticed that detail
– Wendel Siqueira
worked!!! Thanks for the help.
– Antonio Belloni