Reputation: 24709
I am in reference to Angular 2 documentation about the RC router route parameters:
Here is what is mentioned in the documentation about constructing a router link with a route parameter:
['HeroDetail', { id: hero.id }] // {id: 15}
This is supposed to produce the following link:
localhost:3000/hero/15
I have the following link:
<a [routerLink]="['/dashboard/messageconversation/', {otherId: getOther(message).id}]">
and it produces the following link (notice the semicolon as well as the query parameter instead of the route parameter):
http://localhost:8080/dashboard/messageconversation;otherId=2
Here is the @Routes
definition:
{path: '/messageconversation/:otherId', component: MessageConversationComponent}
Can anyone please tell me what I am getting wrong?
Upvotes: 0
Views: 1420
Reputation: 24709
It turns out the proper way to add a route parameter (as opposed to query parameter) is to pass the parameter as the second element of the array as follows:
<a [routerLink]="['/dashboard/messageconversation', getOther(message).id]">
Credits go to stuntbaboon for directing me to the relevant post.
Upvotes: 3