0
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 show in a table.
I know that I must use forEachs to access this data, however, I can’t understand the logic for after picking, how to show in the table (ng-repeat inside a foreach?)
I did this foreach structure, I was able to access the data, but not in the right 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)
})
You have the Json there?
– novic
I edited the question, it’s in hand!
– Fred
Okay, but you need to work on that
Json
– novic
I copied JSON from "studio 3T for MONGODB", so it looks like this hahah. The return is pretty much the way you said it. Thank you so much for your help!
– Fred