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
Provide information on loaded lazy routes on RouteConfigLoadEnd #16282
[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
When accessing modules lazily, RouteConfigLoadEnd gets fired once the factory gets loaded, but before routes are loaded and assigned to route._loadedConfig.
Expected behavior
RouteConfigLoadEnd should be fired after _loadedConfig is assigned, or return routes as a parameter if it's fired from RouterConfigLoader.
What is the motivation / use case for changing the behavior?
Most common use case of RouteConfigLoadEnd is to react once lazy loaded routes are loaded. In localize-router we can use this information for routes localization. However if even is fired before routes are de facto available in _loadedConfig and/or it doesn't provide this information it makes the entire event unusable as it's not that different from RouteConfigLoadStart.
@marko999, actually localize-router no longer depends on this.
With the help from @vsavkin, there is a workaround using SystemJsNgModuleLoader that solves the lazy loading problem and does not require changes in the Router's code.
So unless there are some other interested parties in this feature, this issue can be closed.
Maybe extending SystemJsNgModuleLoader would work for you as well?:
exportclassYourCustomLoaderextendsSystemJsNgModuleLoader{load(path: string): Promise<NgModuleFactory<any>>{returnsuper.load(path).then((factory: NgModuleFactory<any>)=>{return{moduleType: factory.moduleType,create: (parentInjector: Injector)=>{constmodule=factory.create(parentInjector);constgetMethod=module.injector.get.bind(module.injector);module.injector['get']=(token: any)=>{constgetResult=getMethod(token);if(token===ROUTES){// This is the place where routes are loaded, but not yet returned// Do some custom magic here, throw a custom event etc.returngetResult;}else{returngetResult;}};returnmodule;}};});}}
You can see how it was (mis)used in localize-routerhere.
Hi,
I have a problem with the nested routes of a Lazy Loaded module,throwing an error when navigating between child routes, is that a normal behavior from the angular router? I mean will we see any solution other than we extending the SystemJsNgModuleLoader.
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
Activity
TaridaGeorge commentedon Aug 30, 2017
+1
marko999 commentedon Nov 29, 2017
+1
important, also some router implementations like localize-router depending on this
meeroslav commentedon Nov 29, 2017
@marko999, actually
localize-routerno longer depends on this.With the help from @vsavkin, there is a workaround using
SystemJsNgModuleLoaderthat solves the lazy loading problem and does not require changes in the Router's code.So unless there are some other interested parties in this feature, this issue can be closed.
@conor-mac-aoidh, @brandonroberts, @johnpapa, are you still interested in having this event as mentioned in #14036?
Maybe extending
SystemJsNgModuleLoaderwould work for you as well?:You can see how it was (mis)used in
localize-routerhere.hdrdiab commentedon Nov 30, 2017
Hi,
I have a problem with the nested routes of a Lazy Loaded module,throwing an error when navigating between child routes, is that a normal behavior from the angular router? I mean will we see any solution other than we extending the
SystemJsNgModuleLoader.HMubaireek commentedon Jun 3, 2019
The mentiond solution by @meeroslav doesn't work anymore as SystemJsNgModuleLoader got depricated with Angular 8
angular-robot commentedon Jun 4, 2021
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
angular-robot commentedon Jun 25, 2021
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
atscott commentedon Feb 1, 2022
Closing as duplicate of #40010 / #44577 / #24069
angular-automatic-lock-bot commentedon Mar 4, 2022
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.