I have the following json array which i have destructured from a service response in my angular application.
this.selectedList = [
[
{
"meterNumber": "Z00001410",
"utilType": "elec",
"mprnGprn": "3100000334",
"isChecked": true
},
{
"meterNumber": "Z00001410",
"utilType": "gas",
"mprnGprn": "1000003344",
"isChecked": true
}
],
[
{
"meterNumber": "Z00001410",
"utilType": "elec",
"mprnGprn": "1000003344",
"isChecked": true
}
],
[
{
"meterNumber": "Z00001410",
"utilType": "elec",
"mprnGprn": "1000003344",
"isChecked": true
}
]
]
What i need to do is to iterate through the list and change the isChecked value to false on a click event. I have tried the following
selectAll(){
this.selectedList = this.data.reportList.map((meter) => meter.pm);
this.newList = this.selectedList.map((data) => {
data.forEach(item => item.isChecked = false);
});
console.log(this.newList);
}
the above code is changing the value to false, but when i try to console the newList, its an array of undefined values. Is it the best way to do this or what am i doing wrong here.
Thanks in Advance.
mapneeds to return a value.