![](/img/trans.png)
[英]Angular 8 routerLinkActive doesn't work with ng-template
[英]routerLinkActive with dynamic url doesn't work Angular 9
我有以下 html 模板:
<a [routerLink]="'/views/' + typeParam + '/my-recently-updated'" routerLinkActive="active">some text</a>
當我單擊該鏈接時,我看到項目被選中,但是當我重新加載頁面(按 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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.