Angular : Resetting the state of services when Lazy Loaded Module reloads

随声附和 提交于 2019-12-24 17:12: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.

来源:https://stackoverflow.com/questions/51311713/angular-resetting-the-state-of-services-when-lazy-loaded-module-reloads

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!