Reputation: 1826
Using Angular, I have created a table where users can select people. When a person is selected, they are added to an array named selectedUsers
. When a user clicks the "Select" button they should be taken to the PrintComponent from the ProfileComponent.
I have my routerlink set with:
routerLink="['/print/', selectedUsers]"
When clicking the "Select" button, I am getting the following error:
Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '%5B'/print/',%20selectedUsers%5D'
How can I correctly pass the selectedUsers
array as a route parameter?
I have created a StackBlitz for this issue.
Upvotes: 0
Views: 5599
Reputation: 3976
Well your stackblitz POC is doing routerLink="['/print/', {users:[selectedUsers}]"
this which is not following what routerLink
expects.
If you check this documentation you will see that the routerLink
expects an array of routes or a single route element passed in an array.
Take a look at my stackblitz POC where I have updated profiles component html
and passed selected user ids as comma separated string to the route.
Upvotes: 3