Javascript NgRx减速器支柱值始终未定义
我有一个可以正确返回数据的效果,我使用效果中的数据调用一个操作,但是减速机“detailsList”总是未定义 效果调用CustomAction.ShowDetails(道具数据) 影响Javascript NgRx减速器支柱值始终未定义,javascript,angular,redux,ngrx,ngrx-store,Javascript,Angular,Redux,Ngrx,Ngrx Store,我有一个可以正确返回数据的效果,我使用效果中的数据调用一个操作,但是减速机“detailsList”总是未定义 效果调用CustomAction.ShowDetails(道具数据) 影响 response.student.details always has data so the response is correct if (response === "test") { return of(CustomAction.ShowDetails(response.student.de
response.student.details always has data so the response is correct
if (response === "test") {
return of(CustomAction.ShowDetails(response.student.details));
}
减速器
export interface StudentState {
newStudentDetails: any[];
}
export const studentInitialState: StudentState = {
newStudentDetails: null;
};
const reducer = createReducer(
studentInitialState,
on(CustomAction.ShowDetails, (state, { detailsList}) => ({
...state,
newStudentDetails: detailsList
})),
);
export function createStudentReducer(
state: StudentState,
action: Action
) {
return reducer(state, action);
}
detailsList始终未定义
行动
export const ShowDetails = createAction(
CustomActionTypes.ShowDetails,
props<{ detailsList: any[] }>()
);
export const ShowDetails=createAction(
CustomActionTypes.ShowDetails,
道具()
);
调试减速机时,detailslist始终未定义。有什么想法吗?你必须这样做:
返回(CustomAction.ShowDetails({detailsList:response.student.details}));
返回(CustomAction.ShowDetails(response.student.details))代码>。。。关于操作员的,您是否在switchMap
,mergeMap
。。。我的意思是,一个将输入映射到另一个可观察对象的操作符?@julianobrasil是的,在switchMap下