2

如何forFeature在 ngrx 中使用不用于延迟加载的模块?

在我的应用程序中,每个模块都应该有自己的 reducer

StoreModule.forFeature('feature', featureReducers, { metaReducers }),

我该如何实施?

4

1 回答 1

2

因此,在app.module.ts我们提到StoreModule.forRoot(reducer, {})为主应用程序注入 store 的 so 中,当我们延迟加载路由时,我们需要添加StoreModule.forFeature('lazyModule', reducer)您的延迟模块,并且您需要在您的应用程序路由文件中以以下格式导入模块。

{ path: 'lazy', loadChildren: '../lazyComponent/lazy.module#LazyModule'},

然后当我们访问该路由时,reducer 会动态注入。

于 2018-05-29T07:03:22.780 回答