You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Inject,Injectable}from'@angular/core';import{Http}from'@angular/http';import{Observable}from'rxjs/Rx';
@Injectable()exportclassAppConfig{publicstaticconfig: Object=null;publicstaticenv: Object=null;constructor(privatehttp: Http){}publicstaticget(key: any){returnAppConfig.config[key];}publicstaticgetEnv(key: any){returnAppConfig.env[key];}/** * This method: * a) Loads "env.json" to get what is the current environment (e.g.: 'production', 'development') * b) Loads "config.[env].json" to get all env's variables (e.g.: 'config.development.json') */publicload(){returnnewPromise((resolve,reject)=>{if(AppConfig.config!=null||AppConfig.env!=null){returnresolve(true);}this.http.get('env.json').map(res=>res.json()).subscribe((envResponse)=>{AppConfig.env=envResponse;letrequest:any=null;switch(envResponse.env){case'production': {request=this.http.get('config.'+envResponse.env+'.json');}break;case'development': {request=this.http.get('config.'+envResponse.env+'.json');}break;case'default': {alert('Database adapter not defined');}break;}request.map(res=>res.json()).catch((error: any)=>{console.error(error);reject(error);returnObservable.throw(error.json().error||'Server error');}).subscribe((responseData)=>{AppConfig.config=responseData;resolve(true);});});});}}