我的应用程序中有以下控制器:
angular.module('myApp.controllers',[]).
controller('ClientesController',[ '$scope','$rootScope','Clientes',function($scope,$rootScope,Clientes) {
$rootScope.clientes;
Clientes.query(function(response) {
$rootScope.clientes = response;
})
}]);
它返回具有以下格式的JSON对象:
[{"idCliente":1,"nomeFantasia":"Flores","razaoSocial":"Transportes Flores Ltda.","contatosClientes":
[
{"idContatoCliente":1,"dddCelular":21,"email":"ljames@cavaliers.com"},{"idContatoCliente":2,"email":"test@cavaliers.com"}
]
}]
还有一个试图用ng-repeat解析JSON的模板:
{{cliente.idCliente}}{{cliente.razaoSocial}}{{cliente.nomeFantasia}}{{cliente.contatosClientes.email}}问题是我可以使用object.key sintaxe访问外键(idCliente,razaoSocial等),但我无法访问嵌套数组中的内部键(例如contatosClientes.email).
我已经尝试了很多方法,我开始认为我的REST API有问题,但在更改所有后端代码之前,我想知道是否有人可以帮我解决这个问题.
最好的祝福,
Antonio Belloni