是否可以,如果可以,那么如何在同一服务文件中具有多个解析器
以下两个预留器在路由模块中的调用如下
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();
}
}