我有一个对象数组(我们称其为arr
).在(change)
方法中我的组件输入之一中,我修改了这些对象的属性之一,但是在视图(*ngFor
)中什么都没有改变.我读到Angular2更改检测不判断数组或对象的内容,所以我try 了以下方法:
this.arr = this.arr.slice();
和
this.arr = [...this.arr];
But the view doesn't change, it still shows the old attribute. In the (change)
method with console.log()
I got the correct array. Weird, but this one works: this.arr = [];
I tried NgZone
和 markForCheck()
too.