Angular 7 ngrx编辑存储,无需特定操作
我调用ngrx操作,并将结果保存在组件局部变量中。 如果我编辑此副本而不保存它。。。如果没有具体的行动,当我离开路线时,商店会自动更新 我的代码:Angular 7 ngrx编辑存储,无需特定操作,angular,ngrx,ngrx-store,angular7,Angular,Ngrx,Ngrx Store,Angular7,我调用ngrx操作,并将结果保存在组件局部变量中。 如果我编辑此副本而不保存它。。。如果没有具体的行动,当我离开路线时,商店会自动更新 我的代码: this.templatesLoaded .pipe(untilComponentDestroyed(this)) .subscribe((loaded: boolean) => { if (loaded) { this.templateObs .pipe(untilCompone
this.templatesLoaded
.pipe(untilComponentDestroyed(this))
.subscribe((loaded: boolean) => {
if (loaded) {
this.templateObs
.pipe(untilComponentDestroyed(this))
.subscribe((tmpl: ProjectTemplate) => {
this.template = { ...tmpl }; // <-- THIS IS MY COPY
现在,如果我离开路线,商店将更新,“字段”将减少一个
怎么可能呢
如果我使用redux Chrome插件跟踪事件,则不会触发任何操作。。。只有路由器导航
谢谢大家 对象rest spread操作符
{…}
,只复制一层深度
状态可能因此而更改,要修复此问题,您必须复制属性,例如
{ fields: ...tmpl.fields }
{ fields: ...tmpl.fields }