Angular 7直接url路由不支持id

问题描述 投票:0回答:1

如果我单击导航链接,则单击按钮上的代码上面写着]

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 {}
angular typescript angular2-routing
1个回答
0
投票

[尝试使用html标签和路由器链接从<a>测试它

      <a [routerLink] = "['dashboard', selectedDateString]" href="javascript:;"></a>
© www.soinside.com 2019 - 2024. All rights reserved.