Hook into router config loading
See original GitHub issueπ feature request
Relevant Package
This feature request is for @angular/router
Description
Router.resetConfig allows you to basically post process router at application startup - e.g. replace static placeholders, translate urls, mass add route data etc.). However you donβt get a chance to do this for lazy loaded components.
Describe the solution youβd like
Add some possibility to hook into the RouterConfigLoader
when routes from the child modules are processed (e.g. a provider that would be called with the routes resolved from the just loaded moduleβs injector - https://github.com/angular/angular/blob/master/packages/router/src/router_config_loader.ts#L43).
Describe alternatives youβve considered
The way to get around this is implemented in localized-router: https://github.com/Greentube/localize-router/blob/master/src/localize-router-config-loader.ts. This is a hack in the first place and will not work with the new loadChildren syntax.
The solution which would support also the new syntax is here: https://github.com/gilsdav/ngx-translate-router/blob/master/projects/ngx-translate-router/src/lib/localized-router.ts which is an even bigger hack.
/cc @gilsdav @meeroslav Pls comment if you have any thoughts on this.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:5 (3 by maintainers)
Top GitHub Comments
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.
I would like to see a clean way to intercept the routes on lazy loading.
While I donβt consider the
localize-router
solution with overriding a System JS Loader a hack, it was clearly not future proof (although at that time best solution as discussed with @vsavkin).Linking the previous feature request here: https://github.com/angular/angular/issues/16282 as well as https://github.com/angular/angular/issues/14036