我正在尝试在导航到儿童路线之前解析数据,因为我必须在儿童警卫中使用该数据。问题是父解析器,在子守卫被解雇后解析数据。解析器需要很长时间才能解析数据
// app.module.ts
const appRoutes: Routes = [
{ path: 'login', component: LoginComponent },
{
path: '',
component: SiteLayoutComponent,
children: [
{ path: '', redirectTo: 'warehouse', pathMatch: 'full' },
{
path: 'warehouse',
loadChildren: './warehouse/warehouse.module#WarehouseModule'
// loadChildren: () => WarehouseModule
}
],
canActivate: [AuthGuard],
resolve: {
Site: SiteResolver // should be resolved before the guard is invoked.
}
},
{ path: '**', component: PageNotFoundComponent }
];
// warehouse.module.ts
const appRoutes: Routes = [
{ path: '', redirectTo: 'cash', pathMatch: 'full' },
{ path: 'cash', component: CashComponent, canActivate: [RouteGuard] // should be invoked after the parent resolver resloves th data }
];
在这里,父解析器(即 SiteResolver)在子守卫(即 RouteGuard)被调用后解析。我想要的是 SiteResolver 首先解析数据,然后 RouteGuard 应该触发,我该如何实现?