我有以下 html 模板:
<a [routerLink]="'/views/' + typeParam + '/my-recently-updated'" routerLinkActive="active">some text</a>
当我单击该链接时,我看到项目已被选中,但是当我重新加载页面(按 F5)时,我看不到任何选定的项目。
views-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>
关于angular - 具有动态 url 的 routerLinkActive 不起作用 Angular 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61887396/