Reputation: 153
I want to create a details page in Angular and want to pass an entry id with the RouterLink. Is there a way to get the parameter in the url?
The URL looks like: http://localhost:8080/details?date=13-09-2016
Upvotes: 2
Views: 489
Reputation: 271
Also RouteParams can be used to get the parameter. You can injected it to your component:
@Component(...)
class MyDetailsComponent {
final RouteParams _routeParams;
MyDetailsComponent(this._routeParams){
var date = _routeParams.get('date');
}
}
You can find more details here.
Upvotes: 2
Reputation: 657318
Implement OnActivate
@override
routerOnActivate(ComponentInstruction nextInstruction,
ComponentInstruction prevInstruction) {
String routeParamValue = nextInstruction.params['paramName'];
String queryParamValue = nextInstruction.urlParams['paramName'];
}
Upvotes: 1