Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 Dart - Dynamic Routing

Im working in Angular 2 Dart, but I should be able to translate any JS or TS examples.

1) How can I gain a list of all the registered routes?

2) How can I delete a route from the registered routes?

I know I can dynamically add via something like this:

  ...
  final Router router;

  AppComponent(this.router){
    this.router.config([
      Route(path: '/Page-0', component: Page0Route, name: 'Page-0')
    ]);
  }
  ...

But yet to work out listing and removing routes.

like image 970
Alex Haslam Avatar asked Jan 20 '26 05:01

Alex Haslam


1 Answers

As far as I know there is currently no official way. The RouteRegistry contains the configured routes but it doesn't provide public members to access them and in Dart you can't access private fields like you can in TypeScript to work around this limitation.

The only workaround that I see is to extend the RouteRegistry class and add your custom implementation as provider for the RouteRegistry type, after ROUTE_PROVIDERS to ensure your custom implementation is taken instead. I haven't tried this yet though.

like image 99
Günter Zöchbauer Avatar answered Jan 22 '26 18:01

Günter Zöchbauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!