如果我单击导航链接,则单击按钮上的代码上面写着]
this.router.navigate(['/dashboard', this.selectedDateString]);
并且当我手动输入URL时,它工作正常
http://myapp/dashboard/01152020
我被禁止了!信息。为什么从应用程序内部而不是直接进行路由
这是我的路由模块
const appRoutes: Routes = [
{ path: 'dashboard/:date', component: DashboardComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
@NgModule({
imports: [
RouterModule.forRoot(
appRoutes, { onSameUrlNavigation: 'reload' }
)
],
exports: [
RouterModule
]
})
export class AppRoutingModule {}
[尝试使用html
标签和路由器链接从<a>
测试它
<a [routerLink] = "['dashboard', selectedDateString]" href="javascript:;"></a>