1

How can I access the querystring parameters from my component? I have URLs like this:

http://myurl.com/myroute?myparam=1

thanks

1 Answer 1

2

Hint The RC.1 @angular/router is also deprecated. It's better to stick with @angular/router-deprecated (because it has more features and is quite stable) until a new new router is shipped.


If you are using router-deprecated then constructor(private params: RouteParams) will give you access to all parameters, then you can get specific parameter by params.get('myparam')

working of Router in RC is not yet documented, but you can get hold of params in routerOnActivate

routerOnActivate(curr: RouteSegment, prev?: RouteSegment, 
             currTree?: RouteTree, prevTree?: RouteTree): void {
  let myparam = curr.getParam("myparam");
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.