blob: 4d2b09870892bfdf66a386cfe5b59bb92fb446e7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { IConfig } from '../app/_data/IConfig'
@Injectable()
export class Configuration {
static settings: IConfig;
constructor(private http: HttpClient) { }
load() {
const jsonFile = 'assets/config.json';
return new Promise<void>((resolve, reject) => {
this.http.get(jsonFile).toPromise().then((response) => {
Configuration.settings = <IConfig>response;
resolve();
}).catch((response: any) => {
reject(`Could not load file '${jsonFile}': ${JSON.stringify(response)}`);
});
});
}
}
|