我正在使用 Angular 5,我的 routerLinkActive 不起作用,并在刷新页面后显示我的参数未定义。
这是我的路线:
const childRoutes: Routes = [
{
path: '', data: { expectedRole: 'ADMIN' }, canActivate: [RoleGard],
children: [
{ path: '', redirectTo: 'list', pathMatch: 'full' },
{ path: 'list', component: MembersListComponent },
]
},
{
path: ':id', data: { expectedRole: 'ADMIN' }, canActivate: [RoleGard],
children: [
{ path: '', redirectTo: 'edit', pathMatch: 'full' },
{ path: 'edit', component: MemberEditComponent },
{ path: 'status', component: MemberStatusComponent },
{ path: 'delete', component: MemberDeleteComponent }
]
}
];
在我的导航栏中,我显示这样的子路线:
<a class="navbar-navItem" [routerLink]="['members', id, 'edit']" routerLinkActive="active">
<span class="navbar-navItem-text">{{ 'NAV_BAR.member.edit'|translate }}</span>
</a>
<a class="navbar-navItem" [routerLink]="['members', id, 'status']" routerLinkActive="active">
<span class="navbar-navItem-text">{{ 'NAV_BAR.member.status'|translate }}</span>
</a>
<a class="navbar-navItem" [routerLink]="['members', id, 'delete']" routerLinkActive="active">
<span class="navbar-navItem-text">{{ 'NAV_BAR.member.delete'|translate }}</span>
</a>
例如,当我导航到“编辑”路线时,它可以完美运行。但是当我按 F5 时,activeRouterLink 不起作用。如果我导航到“状态”,它会再次起作用。
任何想法 ?提前致谢