【问题标题】:Why is my ngrx Effect transforming a string parameter into an array?为什么我的 ngrx Effect 将字符串参数转换为数组?
【发布时间】:2020-09-16 19:42:00
【问题描述】:

动作

我有以下操作:

export const searchTM = createAction(
    IocActionTypes.SearchTM,
    props<{tm: string}>()
);

组件

我的一个组件中有以下代码:

this.store.dispatch(searchTM(value));  

其中value 是字符串03F

效果

在我的 ngrx 效果文件中,我有以下内容:

searchTM$ = createEffect(() => this.actions$.pipe(
    ofType(iocActions.searchTM),
    mergeMap(val => this.iocService.getGridRowByTM(val.tm)
      .pipe(
        map(rowdataraw => iocActions.searchTMFound({rowdataraw})),
        catchError(() => {
            return EMPTY;
        })
      )
      )
    )
  );

但是当我在 mergeMap val 变量上设置调试点时,我看到它是这样出现的:

【问题讨论】:

    标签: angular ngrx ngrx-store ngrx-effects


    【解决方案1】:

    问题是我以错误的格式传递参数。

    我正在使用:

    this.store.dispatch(searchTM(value));  
    

    我应该使用的地方:

    this.store.dispatch(searchTM({tm: value}));
    

    【讨论】:

    • 谢谢我遇到了同样的问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-28
    • 2014-05-16
    • 2017-12-07
    • 1970-01-01
    相关资源
    最近更新 更多