I have a resolve that is calling getSchools() from service
resolver.ts
export abstract class APIResolverService implements Resolve<any> {
constructor(readonly dropdownService:DropDownOptionsService,readonly route:ActivatedRoute) { }
abstract resolve();
}
export class APISchoolsresolve extends APIResolverService{
resolve(){
this.route.queryParams.subscribe(params => {
let district = params['district'];
return this.dropdownService.getSchools(district);
})
}
My Service
async getSchools(districtID:number){
return await this.http.get<ISchool[]>(`api/GetSchools/` + districtID).toPromise();
}
My Component
this.activatedRoute.data.subscribe((data) =>{
console.log(data);
})
my data in component is undefined as it is being called before my resolver get data.
How do I fix this?