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
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).