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

时间:2018-09-07 07:40:49

标签: angular path routing guard

Ts

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

];

当我进入仪表板路径并重新加载时,我得到一个空页面,如何解决此问题,请帮帮我吗?

1 个答案:

答案 0 :(得分:0)

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

@NgModule({
    imports: [/*your imports */,
              RouterModule.forRoot([/*your routes here*/], { initialNavigation: 'enabled' })],
    exports: []
})
export class AppModule {}