Closed housseindjirdeh closed 7 years ago
@housseindjirdeh I think that the problem with this section is that we are not defining a component to share between the root module and the lazy loaded to better explain the problem. Right now importing the SharedModule
in the LazyModule
is not needed because the child injector created by the lazy loaded module will still have access to the CounterService
defined in the root injector. But we need to explain a more general problem. What if we also have a component (or a pipe or a directive) defined in the SharedModule
that we need to use in the RootModule
and LazyModule
? That's the real question for this section.
Thanks for this @barretodavid, and you're right it would make more sense to explain how we can import such a module. Will write up another section to explain what to do in this scenario by tomorrow.
Updated the section to explain things in a little more detail. I first explain how you don't have to reimport SharedModule
with only a core service since it's defined at the root level. I then introduce a HighlightDirective
to explain why you may still need to import the module in your lazy loaded module.
Let me know if you think I should change anything!
@barretodavid if you have capacity can you see if your AC is met?
Good job explaining the problem @housseindjirdeh. I know a lot of people outside of Rangle have a hard time understanding how the injector tree works with lazy loading. They might find this section helpful.
Thank you David 😊
Removes reimport of
SharedModule
in lazy loaded module (defined withforRoot
in application root module)