user10623427
user10623427

Reputation:

Angular variable into routerLink

I'm trying to pass an id in my routerLink, how could I concatenate it?

<a routerLink="['/details', {{data.id}}]"> </a> doesnt work.

Do you have solutions?

Thanks in advance

Upvotes: 21

Views: 25027

Answers (3)

Mike
Mike

Reputation: 71

Similar to above, but you can also do this:

<a [routerLink]="['/details' + data.id]"> Link </a>

Upvotes: 1

Oen44
Oen44

Reputation: 3206

There you go.

<a [routerLink]="['/details', data.id]"> Link </a>

Upvotes: 37

Aragorn
Aragorn

Reputation: 5289

Parameters go as second item in the array syntax to router link, like this:

[routerLink]="['/details', data.id]

Read more here

Upvotes: 7

Related Questions