简体   繁体   中英

angular route path with parameters separated with &

This type of path is not working:

{ path: 'account/finalize?user=:user&token=:token', component: MyComponent }

I get route not found error when I access http://localhost:4200/account/finalize?user=devanshu&token=122323

But this is working:

{ path: 'account/finalize/:school/:token', component: MyComponent }

So, I can access http://localhost:4200/account/finalize/devanshu/122323

What is the problem here? Why is there an error in the first case?

you can use

path: 'account/finalize'

and send user and token as query Params when navigating

this.router.navigate(['/account/finalize'], { queryParams: { user: 'user', token: 'your token' } });

I think you do not need to pass these parameters: user=:user&token=:token

You can get these parameters in the req.body

And if there is any particular component then you have to place the condition within the function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM