Angular 角度4+;。在解析程序运行时显示微调器

Angular 角度4+;。在解析程序运行时显示微调器,angular,typescript,spinner,angular-resolver,Angular,Typescript,Spinner,Angular Resolver,在解析程序执行某些工作时,是否可以显示微调器而不是空页 我有一个带有两个解析器的模块: const routes: Routes = [ { path: '', component: MyComponent, canActivate: [MyAuthGuard], resolve: { vehicles: FirstResolve, drivers: SecondResolve }, children: [

在解析程序执行某些工作时,是否可以显示微调器而不是空页

我有一个带有两个解析器的模块:

 const routes: Routes = [
  {
    path: '',
    component: MyComponent,
    canActivate: [MyAuthGuard],
    resolve: {
      vehicles: FirstResolve,
      drivers: SecondResolve
    },
    children: [
      {
        path: '',
        component: FirstComponent
      },

      {
        path: ':id',
        component: SecondComponent
      }
    ]
  }
];
每个解析器都会执行一些耗时的操作,如向服务器发出请求:

@Injectable()
export class FirstResolve implements Resolve<Entity[]>{

  constructor(
    private _firstService: FirstService,
    private _secondService: SecondService,
    private _store: Store<any>
  ) { }

  async resolve(): Promise<Entity[]> {
    let data = await Promise.all([
      this._firstService.getEntities(),
      this._secondService.getEntities()
    ]);

    this._store.dispatch(...);
    this._store.dispatch(...);

    return;
  }

}
@Injectable()
导出类FirstResolve实现解析{
建造师(
private\u firstService:firstService,
私人二级服务:二级服务,
私人商店:商店
) { }
异步解析():承诺{
让数据=等待承诺([
这是。_firstService.getEntities(),
这是。_secondService.getEntities()
]);
这个._商店.发货(…);
这个._商店.发货(…);
返回;
}
}

你能帮我弄清楚吗?

看这里:@Rohit Sharma,这是路线变更的原因。当访问解析器的数据时,这不会运行loader。@RohitSharma我做了同样的操作,还检查了其他类型的事件,如RouteConfigLoadStart和RouteConfigLoaded。正如Harunur Rashid所说,这不会有帮助。@No_Com解析器会在路由移动到您正在使用解析器的目标组件时获取数据,因此当路由启动时,解析器会获取数据,直到未获取数据为止,您可以显示微调器,表示与post中相同的布线开始事件,并在布线结束时隐藏微调器。顺便问一下,你能在上面做个演示吗?