【发布时间】:2021-04-06 08:44:54
【问题描述】:
我有一个关于数据库的 HTML 小部件,它打印在我的页面中。在此 HTML 中,我需要提供指向我的 Angular 应用程序的特定路径的链接。
我试着说:
<div (click)="goThere('1234')" style="cursor:pointer"> goto</div>
<a href="/param/1234" >goto</a>
<a [routerlink]="/param/1234">goto</a>
哪里有一个带有“导航”指令的页面中的功能。
上述解决方案均无效(仅 href 解决方案触发导航,但我丢失了参数)。我想是因为它的代码“出现”实时 e 不是由角度预先解析的。
我的路由配置:
{ path: '' , data: { breadcrumb: 'Home'} ,
children:
[
{
path : '' , component : DashboardComponent , pathMatch: 'full'
},
{
path : 'param/:param' , component : DashboardComponent,
}
]
},
在我的 DashboardComponent 我有:
const param = +this._route.snapshot.paramMap.get('param');
if (param > 0)
{
this.param = param;
}
有没有办法触发角度路由器系统或使用我的参数转到仪表板组件?
【问题讨论】:
标签: angular