![](/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.