当我再次重新加载页面时,如何重新加载到相同的路径,我正在使用角度4中的活动路由

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

TS

const appRoutes: Routes = [
  {
    path: '',
    redirectTo: 'login',
    pathMatch: 'full'
  },
  {
    path: 'login',
    component: LoginComponent
  },
  {
    path: 'dashboard',
    canActivate: [AuthguardGuard],
    component: MyNavComponent
  },
  { 
  path: '**', 
  redirectTo: 'login', 
  pathMatch: 'full' 
  }

];

当我在仪表板路径并重新加载它时,我得到一个空的网页,如何解决这个请帮助我?

angular path routing guard
1个回答
0
投票

在AppModule路由器配置中启用初始导航。示例如下:

@NgModule({
    imports: [/*your imports */,
              RouterModule.forRoot([/*your routes here*/], { initialNavigation: 'enabled' })],
    exports: []
})
export class AppModule {}
© www.soinside.com 2019 - 2024. All rights reserved.