1
is the following, I have 3 tables. Cities, Organs and Motives. 1 City can have several organs, and 1 organ several motives.
My problem is that in a single page it has to appear all the organs of the city and inside the organ all the motives of the organ. I’m not able to put the motives inside the organ, matter of logic even.
I’m making an ng-repeat of organs 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 motifs inside each organ. But so it’s not working. I wanted to basically put the motifs inside each respective organ ($Scope.orgaos). As if to give a . push, but it doesn’t work on objects.
Good morning @Viniusvilela, seeing your code, I can already get a clue as to what might be going wrong. But can you tell if there is an error in the console? and what the output of
console.log(motivo);
?– mrlew
It returns arrays (organs) with arrays inside (motifs)
– Vinícius Vilela
and no error on console?
– mrlew
No, no error on console
– Vinícius Vilela
I wanted to put the motifs inside each respective organ ($Scope.orgaos) as if to give a . push, but it doesn’t work on objects.
– Vinícius Vilela
What do you get from the two requests are arrays? What is the structure of this data?
– mrlew
[http://imgur.com/ZDbPSLG] This is what returns on the console.log(reason). The first organ has 2 motifs and the second
– Vinícius Vilela
What I get from requests are Objects.
– Vinícius Vilela