Cannot match any routes. for encoded url

59 Views Asked by At

In angular I have route path as a '/friends/message/:key/:type', for which I have a component MessageComponet for this, I tried path '/friend/messages/NzY4OQ==/inbox' ideally, it should navigate me to the path and MessageComponet should render

But in this scenario first I got an error as Cannot match any routes. URL Segment: 'friend/messages/NzY4OQ' Not able to get params['type']

i want to access both key and type

1

There are 1 best solutions below

2
NgDaddy On

= should be encoded and when you navigate with Angular features it happens under the hood.

If you do that outside the Angular ecosystem, try this:

the encoded route address should be .../NzY4OQ%3D%3D/inbox - utilize encodeURIComponent('NzY4OQ==/inbox')

See this example: stackblitz

Try to navigate with this <button routerLink="/friend/messages/NzY4OQ==/inbox">Go To Cmp B</button>