I have this complex array of objects (I'll show only the nodes necessary to explain the problem):
var arr = [
{
json: {
doc: {
id: 1,
atualizacao:{
dc: false
}
}
}
}
]
angular.forEach(arr, function(value, key) {
if(value.json.doc.id == 1){
value.json.doc.atualizacao.dc = true;
}
});
When I do this forEach, it changes the value of the 'dc' node of the array on a specific position. but at the end of the forEach
the array arr
still is still unchanged.
I put many console.logs and found out that:
if i log the variable: value.json.doc.atualizacao.dc - IT SHOWS 'true'
; if i log the variable: value.json.doc.atualizacao - IT SHOWS 'dc = true'
if i log the variable: value.json.doc - IT SHOWS 'atualizacao.dc = true'
if i log the variable: value.json - IT SHOWS 'doc.atualizacao.dc = false'
if i log the variable value - IT SHOWS 'json.doc.atualizacao.dc = false'