4

I have router

{
  path: 'reset-password',
  component: ResetPasswordComponent,
}

And I want to be able to open it as a direct link (/reset-password), or with passed parameters (/reset-password?uid=gsSxc&code=DsdxFSd), and so when creating a router snapshot I want to see the passed parameters.

How can I do this? Do I need to create two different routers for this?

2
  • /reset-password&uid=gsSxc&code=DsdxFS put ? after /reset-password to be /reset-password?uid=... Commented Mar 21, 2019 at 0:50
  • @VolodymyrBilyachat yes, but how should I define path in my router? Commented Mar 21, 2019 at 0:52

1 Answer 1

6

You don't need to have separate route since all query params are always optional and you should handle required parameters inside of your component.

Or define your required parameters in url to be path: 'reset-password/:uid', and path optional parameters via query String reset-password/1234?queryString=true

Sign up to request clarification or add additional context in comments.

1 Comment

You could also handle them in a route guard.

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.