openaire-library/utils/properties/environmentSpecificResolver.ts

24 lines
892 B
TypeScript

import { Injectable } from '@angular/core';
import { Router, Resolve, RouterStateSnapshot,
ActivatedRouteSnapshot } from '@angular/router';
import { EnvProperties } from './env-properties';
import { EnvironmentSpecificService } from './environment-specific.service';
@Injectable()
export class EnvironmentSpecificResolver implements Resolve<EnvProperties> {
constructor(private envSpecificSvc: EnvironmentSpecificService, private router: Router) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<EnvProperties> {
console.log("Here!!!!!!!");
return this.envSpecificSvc.loadEnvironment()
.then(es => {
this.envSpecificSvc.setEnvProperties(es);
return this.envSpecificSvc.envSpecific;
}, error => {
console.log(error);
return null;
});
}
}