我有一条路线孩子这样的路线:
{
path: 'dashboard',
children: [{
path: '',
canActivate: [CanActivateAuthGuard],
component: DashboardComponent
}, {
path: 'wage-types',
component: WageTypesComponent
}]
}
在浏览器中我想获得激活的父路线
host.com/dashboard/wage-types
如何获得 /dashboard
但可以使用Angular 2而不是JavaScript,但我也可以接受JavaScript代码,但主要是Angular 2 .
1 回答
您可以通过使用ActivatedRoute上的父属性来执行此操作 - 类似这样 .
您可以在此处更详细地查看ActivatedRoute中的所有内容:https://angular.io/api/router/ActivatedRoute