I have the following object:
{
"_id" : ObjectId("5a0ae1a032e3762988cddb11"),
"numeroBo" : NumberInt(4),
"relato" : "aaaa",
"modus" : "bbb",
"falhasApuradas" : "aaaa",
"eventosDeRisco" : [
],
"acoesCriminosas" : [
],
"alertas" : [
{
"_id" : ObjectId("5a0ae1a032e3762988cddb13"),
"tipoAcao" : [
{
"ticked" : true,
"name" : "Furto com maçarico"
},
{
"ticked" : true,
"name" : "Roubo com furadeira"
}
]
}
],
"veiculos" : [
],
"suspeitos" : [
{
"_id" : ObjectId("5a0ae1a032e3762988cddb12"),
"name" : [
]
}
],
"longitude" : "-52.02091813087464",
"latitude" : "-27.224810663086224",
"fonte" : [
{
"ticked" : true,
"name" : "Polícia Civil"
},
{
"ticked" : true,
"name" : "Gerente"
}
],
"dataCadastro" : ISODate("2017-11-14T12:29:20.721+0000"),
"__v" : NumberInt(0)
}
Json
in the browser console:
I need to get the index data numeroBo
and alertas > tipoAcao > name
and display it in a table.
I know I should use forEachs to access this data, however, I can not understand the logic for after picking, as shown in the table (ng-repeat inside a forEach?)
I made this forEach structure, until I was able to access the data, but not the correct way.
angular.forEach(vm.alertas, function(value, key){
vm.numBo = value.numeroBo
vm.alert = value.alertas
angular.forEach(vm.alert, function(value, key){
vm.acoes = value.tipoAcao
angular.forEach(vm.acoes, function(value, key){
vm.tipoAcao = value.name
})
})
vm.final = {
bo: vm.numBo,
acao: vm.tipoAcao
}
console.log(vm.final.bo, vm.final.acao)
})