Renamed prefixes in angular.json
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
This commit is contained in:
33
projects/common/src/fm/shared/app.config.ts
Normal file
33
projects/common/src/fm/shared/app.config.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import {Inject, Injectable} from '@angular/core';
|
||||
import {HttpClient, HttpXhrBackend} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class AppConfig {
|
||||
|
||||
private config: Object = null;
|
||||
private httpClient: HttpClient;
|
||||
|
||||
constructor(xhrBackend: HttpXhrBackend) {
|
||||
this.httpClient = new HttpClient(xhrBackend);
|
||||
this.config = null;
|
||||
}
|
||||
|
||||
public getConfig(key: any) {
|
||||
if (!this.config.hasOwnProperty(key)) {
|
||||
console.log(`Config key ${key} not set`);
|
||||
}
|
||||
return this.config[key];
|
||||
}
|
||||
|
||||
|
||||
public load(): Promise<any> {
|
||||
return this.httpClient.get('/configuration.json')
|
||||
.toPromise()
|
||||
.then(data => {
|
||||
this.config = data;
|
||||
//return data;
|
||||
})
|
||||
.catch(error => this.config = null);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user