I have a firebase setup application and need to get all documents in a collection before the related component render.
Data is coming through a normal subscription
this.db.getCountryList().subscribe(countryList => this.countryList = countryList); //working, I have the country list now
But when I use a resolver like below, it does not resolve data or nothing happens.
@Injectable()
export class CountryListResolver implements Resolve<Country[]> {
constructor(private db: DatabaseService) { }
resolve(): Observable<Country[]> {
return this.db.getCountryList();
}
}
service
getCountryList(): Observable<Country[]> {
return this.db.collection<Country>(this.countryPath,ref => ref.orderBy('name', 'asc')).valueChanges();
}
routing
{ path: 'geo', component: GeographicalDataComponent, resolve: {countryList: CountryListResolver } },
component
this.route.data.subscribe(data => {
this.countryList = data['countryList'];
});
and registered my resolver in the root module and other non-firebase resolvers are working fine.
Why is this setup resolver not working?
version
firebase:4.11.0
angularfire2:^5.0.0-rc.6.0
angular:^5.2.0