I am trying to get the query params from a url in a component in Angular2
Version: \"angular2\": \"npm:angular2@2.0.0-beta.12\",
I am trying to extract id query
You can get the query params from the _location.path() in the AppComponent. You'd have to parse them yourself. I'm looking for the same thing, and haven't found a better solution.
I hope someone else follows up on this.
RouteParams it's not available in the root component. It's only available to the routable components.
See RouterOutlet soure code, in its activate function, you can see the following
var providers = Injector.resolve([
provide(RouteData, {useValue: nextInstruction.routeData}),
provide(RouteParams, {useValue: new RouteParams(nextInstruction.params)}),
provide(routerMod.Router, {useValue: childRouter})
]);
Basically RouteParams is being injected through RouterOutlet to the routable components, you can't access it in non-routable components (sorry for repeating myself).