Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get route parameters in the AngularDart component in my view?

In AngularDart, how can I get the route parameters from within my component which is in a view?

As far as I have managed to get is that in my router, I believe I should add parameters as such:

'class': ngRoute(
    path: '/class/:year/:month/:day',
    view: 'views/class.html'
),

Then how can I get the year month and day in my component? its a @Component annotated class.

like image 945
Phil Avatar asked Dec 21 '25 12:12

Phil


1 Answers

this should work

@Component(...)
class MyComponent {
  RouteProvider _routeProvider;

  MyComponent(this._routeProvider);

  var year = _routeProvider.parameters['year'];
  ...
}

You let inject the RouteProvider and access the parameters map.

like image 69
Günter Zöchbauer Avatar answered Dec 24 '25 05:12

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!