Lazy loading not working for nested lazy routes
See original GitHub issueNote that at the moment lazy loading doesn’t work for nested routes. If you have route like lazy/lazy_child if you navigate first to lazy and then to lazy_child everything will work. However if you go directly to lazy/lazy_child Router will report unknown route error, since child routes will not be translated before Route matching mechanism kicks in.
Steps to reproduce
- Create a lazy loaded module with nested routes e.g.
// main routes
{ path: 'lazy', loadChildren: 'path/to/some/route/lazy.module#LazyModule' }
// routes in LazyModule
{ path: '', component: LazyComponent },
{ path: 'child', component: LazyChildComponent }
- Navigate to translated version of
/lazy/childin language other thanene.g.
/de/muessiges/kind
Current behavior Router reports NavigationError as route has not been translated at the moment of route matching.
Expected behavior All child lazy routes should be translated and Router should properly find requested route.
Explanation
LocalizeRouter currently listens to RouteConfigLoadEnd, but this event only signals that child module has been loaded. Child routes are still not available. Additionally RouteConfigLoadEnd returns only requested route, not the module factory from which the child routes could be extracted.
Further steps Discuss with Angular team on possible solutions.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:47 (4 by maintainers)

Top Related StackOverflow Question
Finally yes. I will implement the solution in the upcoming days.
Looks like this is not working with nested lazy loading… top level lazy loaded components get loaded but lazy loaded components with routes declared with forChild(routes) get the “Cannot match any routes” error
Here’s an example where the terms/privacy policy page work as expected but the lazy loaded module breaks with the Cannot match any routes error:
And here’s the lazy loaded module’s routes: