Angular variable into routerLink

依然范特西╮ 提交于 2021-02-20 09:05:11

问题


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


回答1:


There you go.

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



回答2:


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

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

Read more here



来源:https://stackoverflow.com/questions/53523472/angular-variable-into-routerlink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!