I have a method that contains an array of objects, and I would like to be able to edit the desiredMin and desiredMax values.
watchedRivers(): RiverInfo[] {
return [
{
name: 'Sample River 1',
address: 'Optional Address 1',
currentFlow: 2.78,
desiredMin: 1.5,
desiredMax: 6
},
{
name: 'Sample River 2',
currentFlow: 857,
desiredMin: 100,
desiredMax: 500
},
{
name: 'Sample River 3',
address: 'Optional Address 1',
currentFlow: 2800,
desiredMin: 400,
desiredMax: 3000
}
];
}
The method I call to do so is not overwriting the object.
updateFlows(index: number, updatedRiver: RiverInfo) {
console.log(updatedRiver);
this.watchedRivers()[index] = updatedRiver;
console.log(this.watchedRivers()[index]);
this.watchedRiversChanged.next(this.watchedRivers().slice());
}
The updatedRiver object looks like the correct format in the console. Why isn't it overwriting?