I'm facing an issue with a complex array of objects (I will only display the necessary nodes 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;
}
});
Even though I use forEach to change the value of the 'dc' node at a specific position in the array, the array arr
remains unchanged at the end of the loop.
Upon further investigation with console logs, I discovered the following:
Logging the variable: value.json.doc.atualizacao.dc - IT SHOWS 'true'
Logging the variable: value.json.doc.atualizacao - IT SHOWS 'dc = true'
Logging the variable: value.json.doc - IT SHOWS 'atualizacao.dc = true'
Logging the variable: value.json - IT SHOWS 'doc.atualizacao.dc = false'
Logging the variable: value - IT SHOWS 'json.doc.atualizacao.dc = false'