Repository navigation
Description
🚀 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.
Activity
meeroslav commentedon Jul 25, 2019
I would like to see a clean way to intercept the routes on lazy loading.
While I don't consider the
localize-routersolution 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: #16282 as well as #14036
imsingh commentedon Jul 26, 2019
I was thinking about how to do this. Maybe it's too naive.
What if RouterConfigLoader's loadModuleFactory takes a second argument
modifier.modifier prototyope
type Modifier = (factory: NgModuleFactory) => NgModuleFactory;
Then Angular puts a default modifier which takes a NgModuleFactory and returns it as it, as following:
but then the user can create their own modifier and provide it within the provider's array.
The
loadModuleFactorywould look something like this: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 24, 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.
angular-robot commentedon Apr 15, 2022
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.
muuvmuuv commentedon Dec 3, 2025
It is already possible to get access to it, here a workaround from my lib, but its not typed as its not exported in the public api. If we could change that and export it, that would be awesome!