EDIT: This problem does not occur when you import HttpClientModule only ONCE in the AppModule or CoreModule (and import the CoreModule into AppModu...
For further actions, you may consider blocking this person and/or reporting abuse
Does this still hold true if the expenses.module imports core.module?
@joekaiser , I think the author was imported HttpClientModule to lazy-module, therefore it accidentally caused the creation of multiple instances. It was his fault.
stackblitz.com/edit/angular-mf67bq
You should never import Core module into your feature modules, because it will create NEW instances of all providers. Core module should be imported only ONCE into App module (root module).
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?
Hi!
I tried to reproduce the problem, but everything seems to be working fine even without the
@SkipSelf()decorator.StackBlitz
Did I miss something?
No, I think he was confused. Look at the docs for skipSelf. I read them as: if you have a dependency defined in the main module and submodule, it allows you to tell angular which one to use.
However, if a dependency is only in the app module, you don't need to sorry about it.
angular.io/api/core/SkipSelf
Andrei, no! I was missing important point! Please take a look at my previous comment, where I gave an explanation. Forgive me for misleading you! 😥 I will update the article!
Just to notice that this is in the docs, in usage notes angular.io/api/common/http/HttpInt...