Working on implementing lazy loading for my Angular 4 application, I have a total of 18 lazy loaded modules. Upon noticing that fetching these modules is taking some time, I decided to add a loading indicator. Everything worked fine when I added it locally to app.component
. However, in production, I kept encountering errors about RouterModule being undefined.
Now, I am unable to access any of the lazy-loaded modules (non-lazy loaded modules work without any issues).
When I removed the loading indicator, things started working again.
I grabbed code from this website
I suspect that the problem arises when adding the router to the constructor of app.component.ts
.
Any guidance or assistance in resolving this issue would be greatly appreciated.
EDIT1:
For reference, here is the code from app.routing.ts