我在我的应用程序中使用NgRx商店。
Home.html
<list-objects
[array]="array| async"
(Edit)="Edit($event)"
(Delete)="Delete($event)"
></list-objects>
Run Code Online (Sandbox Code Playgroud)
Home.ts
export class HomePage {
public array: Observable<itm[]>;
constructor(){
this.array= this.store.select(state => state.array);
this.array.subscribe((a) => {
console.log(a); //VALUES OK
}
}
Edit(event){
this.store.dispatch(this.actions.updateItem(event.item));
}
}
Run Code Online (Sandbox Code Playgroud)
当我编辑数组项时,异步管道不会更新视图,但“数组”对象中的值是正确的(subscribe中的console.log显示更新后的值)。当我单击DOM中的某个位置(打开模式,单击按钮...)时,查看具有新值的更新。
我还登录了子组件“ ngOnChanges”,它不会使用新值触发。