You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preloading of nested lazy modules does not work #49558
Which @angular/* package(s) are the source of the bug?
router
Is this a regression?
No
Description
Preload only works for siblings, not children.
For example, there is a structure:
graph LR
pages --> b
pages --> c
b --> b-review
b --> b-detail
b-detail --> b-maintenance
b-detail --> b-additional
Loading
If you go to /pages/c you'll get only b preloaded. But you could have a link on /pages/c to pages/b/detail/1/maintenance. Therefore, I want to get b-index, b-detail-index, b-detail-component, and b-maintenance preloaded.
There are actually 2 issues here. On is a Router bug (which you can get around by changing children: [...] to loadChildren: () => [...] but the other in your example is that your preloading function is returning Observable<Observable<any>> because of the map returning an Observable.
Activity
Eugeno commentedon Mar 23, 2023
Here's a hacky solution for preloading nested lazy routes:
Thanks to @stevermeister for this idea.
fix(router): Ensure Router preloading works with lazy component and s…
atscott commentedon Mar 23, 2023
There are actually 2 issues here. On is a Router bug (which you can get around by changing
children: [...]toloadChildren: () => [...]but the other in your example is that your preloading function is returningObservable<Observable<any>>because of themapreturning anObservable.https://stackblitz.com/edit/angular-g7jdc3?file=src%2Fapp%2Fpages%2F%2Bb%2Fb-routing.module.ts
Eugeno commentedon Mar 24, 2023
@atscott thanks you so much for your quick response and for proposing a working solution to the issue. Much appreciated!
fix(router): Ensure Router preloading works with lazy component and s…
angular-automatic-lock-bot commentedon Apr 24, 2023
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.