我是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(); }
当我登录到应用程序时,它运行正常,每个页面都成功加载。
当用户按照以下步骤
时会出现问题浏览器仅显示空白页,但是url栏中的uri显示/ declarationofuse url。控制台选项卡中也没有抛出异常。