同一文件中有多个解析器?

时间:2019-03-01 12:33:23

标签: angular

是否可以,如果可以,那么如何在同一服务文件中具有多个解析器

以下两个预留器在路由模块中的调用如下

resolve: {profileDetails: ProfileDetailsResolverService}, 
resolve: {invoiceDetails: InvoiceResolverService},

导出类ProfileDetailsResolverService实现Resolve {       isLoggedIn:boolean = false;

  constructor(private http: HttpClient, private auth: AuthService) { }

  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> {
      if(localStorage.getItem('access_token')){
      return this.auth.getUserProfile();
      }

 export class InvoiceResolverService implements Resolve<any> {

      constructor(private http: HttpClient, private auth: AuthService) { }

      resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> {
        return this.auth.getInvoices();
      }
    }

0 个答案:

没有答案