Angular2,浏览器后退按钮显示空白屏幕

时间:2018-01-24 08:57:35

标签: angular2-routing

我是Angular2的新手。在我的应用中,请找到以下路由配置。

    export const routes: Routes = [
  {
    path: '',
    component: LoginHomepageComponent
  },
  {
    path: 'login',
    component: LoginHomepageComponent
  },
  {
    path: 'contact',
    component: ContactComponent,
    canActivate: [AuthGuard]
  },
  {
    path: 'default',
    component: DefaultNavigationBarComponent
  },
  {
    path: 'mainContent',
    component: MainContentComponent,
    children: [
      { path: '', component: SearchComponent, canActivate: [AuthGuard] },
      { path: 'changepassword', component: ChangePasswordComponent, canActivate: [AuthGuard] },
      { path: 'searchResults', component: SearchResultsComponent, canActivate: [AuthGuard] },
      { path: 'addUser', component: AddUserComponent, canActivate: [AuthGuard], canDeactivate: [UnsavedChangesGuard] }
    ]
  },
  {
    path: 'not-found',
    component: ErrorPageComponent,
    data: {
      message: 'Page not found!'
    }
  },
  {
    path: 'declarationofuse',
    component: DeclarationComponent,
    canActivate: [AuthGuard],
  },
  {
    path: '**',
    redirectTo: '/not-found'
  }
];

export const AppRouting = RouterModule.forRoot(routes, { enableTracing: true });
app.module.ts中的

@NgModule({
  declarations: [
  ],
  imports: [
    AppRouting,
  ],
  exports: [RouterModule],
  providers: [
    UnsavedChangesGuard
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
export function cookieServiceFactory() { return new CookieService(); }

当我登录到应用程序时,它运行正常,每个页面都成功加载。

当用户按照以下步骤

时会出现问题
  • 登录应用程序,自动加载/声明使用uri
  • 现在用户访问google.com,之后用户按下后退按钮

浏览器仅显示空白页,但是url栏中的uri显示/ declarationofuse url。控制台选项卡中也没有抛出异常。

0 个答案:

没有答案