Maks K
Maks K

Reputation: 3914

How use forFeature not for lazy loaded modules?

How use forFeature in ngrx not for lazy loaded modules?

In my application, every module should have his own reducer

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

How can I implement this?

Upvotes: 2

Views: 1502

Answers (1)

Jaya Krishna
Jaya Krishna

Reputation: 313

So, in app.module.ts we mention for StoreModule.forRoot(reducer, {}) so which injects the store for the Main Application, when we are lazy loading a route, we need to add StoreModule.forFeature('lazyModule', reducer) in your Lazy Module and you need to import the module in the below format in your app routes file.

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

Then the reducer and in dynamically injected when we visit that route.

Upvotes: 2

Related Questions