如何在ngrx中使用forFeature
而不是延迟加载模块?
在我的应用程序中,每个模块都应该有自己的 reducer
StoreModule.forFeature('feature', featureReducers, { metaReducers }),
我该如何实现这个?
最佳答案
因此,在 app.module.ts
中,我们提到了 StoreModule.forRoot(reducer, {})
,以便为主应用程序注入(inject)存储,当我们延迟加载路由,我们需要在您的延迟模块中添加 StoreModule.forFeature('lazyModule', reducer)
,并且您需要在应用路由文件中以以下格式导入该模块。
{ path: 'lazy', loadChildren: '../lazyComponent/lazy.module#LazyModule'},
然后当我们访问该路由时,reducer 会被动态注入(inject)。
关于angular - 如何使用 forFeature 而不用于延迟加载模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49896285/