Reputation: 3791
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?
Upvotes: 4
Views: 6316
Reputation: 19484
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
Upvotes: 6