question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 4 years ago
  • Reactions:8
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
angular-robot[bot]commented, 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.

1reaction
meeroslavcommented, 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-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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading Configuration on a Branch Router/Switch | HPE Support
Configuring router for TFTP load: Connect to the console and get to the hash prompt. Type in the following: config term. interface e0...
Read more >
Getting Router config for lazy loaded module in Angular 2 ...
Just declare routes in your code, export them from routing module, and import them where you need them. It's not as nice as...
Read more >
How To Handle Routing in React Apps with React Router
First, get the current path with the useRouteMatch Hook. Next, render the new <Switch> and <Route> components to display the correct components.
Read more >
Common Routing Tasks - Angular
Defining a basic routelink Β· Import RouterModule and Routes into your routing module. The Angular CLI performs this step automatically. Β· Define your...
Read more >
Angular Loading Spinners with Router Events
To achieve this, we'll be using the Angular Router and hooking into some of the events provided. A loading spinner is typically bestΒ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found