Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 7 ngrx编辑存储,无需特定操作_Angular_Ngrx_Ngrx Store_Angular7 - Fatal编程技术网

Angular 7 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

我调用ngrx操作,并将结果保存在组件局部变量中。 如果我编辑此副本而不保存它。。。如果没有具体的行动,当我离开路线时,商店会自动更新

我的代码:

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 }