如何使用 routeLink 导航到动态链接

时间:2021-04-08 05:07:06

标签: string-interpolation angular11 routerlink dynamic-links

我像这样在 app.module.ts 中定义路由

{ path: 'property-detail/:Id', component: PropertyDetailComponent },

然后我给routeLink如下

<li class="list-inline-item">
    <button class="btn btn-primary" [routerLink]="['/property-detail',property.Id]">
      <i class="fas fa-edit"></i>
    </button>
</li> 

但是当我点击按钮时,它显示的 url 为 http://localhost:4200/property-detail/undefined 没有显示 id 的值,我该如何解决这个问题。

0 个答案:

没有答案