Angular : Resetting the state of services when Laz

2019-08-15 04:58发布

I have the following structure in my application with respect to Services-

AppModule (AppComponent and HomeComponent)
|       |      |
Lazy1 Lazy2  Lazy3

My App starts with AppComponent which redirects to HomeComponent which then redirects to one of the Sub-Modules.

All submodules are lazy loaded. Now I start with AppComponent from where I am redirected to one of the Sub-Modules. Now depending on some condition, I am navigating back to HomeComponent which then again redirects to one of the sub-module.

My Problem is that if I again reload any of the Sub-Module with different data then also the services of that sub-module will have same old data. Essentially the services are not recreated as they should due to child injection.

Need help to identify the issue here.

Additional Information -

I have a few common services at App level in AppModule. Then each of the sub-module have a number of services which that module consumes. The app level services are injected in the sub-module services.

0条回答
登录 后发表回答