Angular Routerlink:将父路由字符串与变量连接起来

1 typescript angular angular10

如何添加字符串插值/连接

到下面的路由器链接,它转到父路由,然后是变量链接?

 <a routerLink="../account-information/" + "item.productId">
Run Code Online (Sandbox Code Playgroud)

小智 8

字符串插值

routerLink="../account-information/{{item.productId}}"
Run Code Online (Sandbox Code Playgroud)

属性绑定语法:

[routerLink]="'../account-information/' +item.productId" 
Run Code Online (Sandbox Code Playgroud)

或者

[routerLink]="['../account-information/', item.productId]"
Run Code Online (Sandbox Code Playgroud)