1

I use a corporate framework that builds the navigation of the website based on the router config. So all routes configured in the AppRoutingModule will be displayed in the navigation and its children will be showed on mouse over. The problem now is that, when I have a lazy loaded module, children arent set on the route so I can't iterate over them.

I tried to get the router config of the lazy loaded feature module but that didn't work as router.config returns the config of the AppRoutingModule. Then I searched for a solution to execute code on postload (so after the module has been loaded) but didn't find any functionality provided by Angular.

Does anyone has a solution for this or an idea that might help?

Spitzbueb
  • 5,233
  • 1
  • 20
  • 38
  • You said you searched for a solution to execute code on postload, this would make you lose the benefit of lazily loaded module. If you're ready to do so, then eagerly load it and you might see the children routes in `router.config`. If you want to keep the lazy modules, I'm pretty sure you'll have to duplicate the children routes to include them in the initial chunk. – Guerric P Oct 01 '18 at 13:06
  • @YoukouleleY my idea with that was that I'd add the children once someone loads the module. Initially the "on-hover" subnavigation would *not* be displayed and only once the module has been loaded, the subnavigation would be added. – Spitzbueb Oct 01 '18 at 13:07
  • Ok I got it. Did you take a look at https://stackoverflow.com/questions/40293240/how-to-manually-lazy-load-a-module? – Guerric P Oct 01 '18 at 13:15
  • Hmm I might take a look into it. Thanks. – Spitzbueb Oct 02 '18 at 19:08

0 Answers0