is as follows, I have 3 tables. Cities, Bodies and Reasons. 1 City can have several bodies, and 1 orgão several reasons.
My problem is that in a single page you have to appear all the organs of the city and within the organ all reasons of the organ. I can not put the reasons inside the organ, a matter of logic.
I'm doing an ng-repeat of the bodies that are referenced to the city
$http.get(base_url + 'controlx/functions/getWhere/orgaos/cidades_id/'
+ $stateParams.cidadeId) // Aqui pega os orgãos referenciado a cidade
.success(function(data) {
$scope.orgaos = data;
var i = 0;
var motivo = [];
for (let orgao of $scope.orgaos){
$http.get(base_url + 'controlx/functions/getWhere/motivos/orgaos_id/'+orgao.id) // aqui faz uma repetição referenciado ao orgão.
.success(function(data) {
motivo.push(data);
$scope.orgaos=motivo[i];
i++;
});
}
console.log(motivo);
if (data.length === 0) {
$scope.erro = 'Nenhum Orgão Encontrado';
}
});
So, I was trying to add the reasons within each body. But that's not working. I basically wanted to put the reasons inside each respective org ($ scope.orgaos). Like giving a .push, but it does not work on objects.