Well, that is going to be decided by what you in have in your core module. I guess in the example you gave, this is correct. But if you have a core module that for sharing common pipes and directives you do need to import it in sub modules. angular.io/guide/sharing-ngmodules
Let me back up a step. Are you saying the interceptor registered in your app.module won't load in the submodule without skipself?
What I am saying is that "Angular creates a new Dependency Injector for a lazy-loaded module", what basicaly means that if this submodule is lazy-loaded, then yes.
But, don't take my words seriously, just give it a try in your code :)
Joe, first of all thank you for taking the time to dig deeper into this topic. I need to apologize you. You are 100% right. Since you have HttpClientModule imported at the root level (app module), all is fine. The problem I faced was caused by the fact, that I imported HttpClientModule the second time in the SharedModule... 😥. This really confused me and I am sorry. Finally, I believe the best way is to import HttpClientModule once (in the AppModule or CoreModule).
Again, thanks! I will update the article. Best,
Bartosz
Well, that is going to be decided by what you in have in your core module. I guess in the example you gave, this is correct. But if you have a core module that for sharing common pipes and directives you do need to import it in sub modules. angular.io/guide/sharing-ngmodules
Let me back up a step. Are you saying the interceptor registered in your app.module won't load in the submodule without skipself?
What I am saying is that "Angular creates a new Dependency Injector for a lazy-loaded module", what basicaly means that if this submodule is lazy-loaded, then yes.
But, don't take my words seriously, just give it a try in your code :)
OK, I must be missing the point or something. Take a look at this stack blitz stackblitz.com/edit/angular-hrwzgv
The interceptor is defined in the app.module, and the sub module is lazy loaded.
Click on the sub module link and check the console. The interceptor was run just fine.
What am I doing different?
Nothing. I have never seen that problem before if you load CoreModule in AppModule once.
Joe, first of all thank you for taking the time to dig deeper into this topic. I need to apologize you. You are 100% right. Since you have HttpClientModule imported at the root level (app module), all is fine. The problem I faced was caused by the fact, that I imported HttpClientModule the second time in the SharedModule... 😥. This really confused me and I am sorry. Finally, I believe the best way is to import HttpClientModule once (in the AppModule or CoreModule).
Again, thanks! I will update the article. Best,
Bartosz
It's how we learn, friend! :)