【发布时间】:2020-03-26 05:24:51
【问题描述】:
如何通过 reducer 更新数组中的字段?我试过这个:
const customers = state.filteredCustomers;
for (const customer of customers) {
for (const addr of customer.addresses) {
addr.selected = false;
}
}
return {
...state,
filteredCustomers: customers,
};
但是它会抛出一个错误:
TypeError: Cannot assign to read only property 'selected' of object '[object Object]'
最好的方法是什么?
【问题讨论】:
标签: angular state ngrx reducers