具有动态 url 的 routerLinkActive 不起作用 Angular 9
routerLinkActive with dynamic url doesn't work Angular 9
我有以下 html 模板:
<a [routerLink]="'/views/' + typeParam + '/my-recently-updated'" routerLinkActive="active">some text</a>
当我点击它时 link 我看到项目被选中但是当我重新加载页面(按 F5)时我看不到任何被选中的项目。
观看次数-routing.module.ts:
const viewsRoutes: Routes = [
{
path: '',
component: ViewsComponent,
children: [
{ path: ':type', component: ViewsWrapperComponent },
{ path: ':type/:view_name', component: ViewsWrapperComponent }
]
}
];
@NgModule({
imports: [RouterModule.forChild(viewsRoutes)],
exports: [RouterModule]
})
export class ViewsRoutingModule { }
我该如何解决这个问题?
我是这样解决的:
<a [routerLink]="'/views/' + typeParam + '/my-recently-updated'"
routerLinkActive="active"
[routerLinkActiveOptions]="{ __change_detection_hack__: typeParam }">some text</a>
我有以下 html 模板:
<a [routerLink]="'/views/' + typeParam + '/my-recently-updated'" routerLinkActive="active">some text</a>
当我点击它时 link 我看到项目被选中但是当我重新加载页面(按 F5)时我看不到任何被选中的项目。
观看次数-routing.module.ts:
const viewsRoutes: Routes = [
{
path: '',
component: ViewsComponent,
children: [
{ path: ':type', component: ViewsWrapperComponent },
{ path: ':type/:view_name', component: ViewsWrapperComponent }
]
}
];
@NgModule({
imports: [RouterModule.forChild(viewsRoutes)],
exports: [RouterModule]
})
export class ViewsRoutingModule { }
我该如何解决这个问题?
我是这样解决的:
<a [routerLink]="'/views/' + typeParam + '/my-recently-updated'"
routerLinkActive="active"
[routerLinkActiveOptions]="{ __change_detection_hack__: typeParam }">some text</a>