Last active
January 26, 2019 19:38
-
-
Save whisher/3605d55e561bc6a37a78243fd436dd0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Inject, Injectable } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { CONFIG, Config } from '../config.module'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class ConfigLoaderService { | |
configUrl: string; | |
_config: any; | |
constructor( | |
private http: HttpClient, | |
@Inject(CONFIG) private config: Config | |
) { | |
this.configUrl = config.api.config; | |
} | |
get values() { | |
return this._config; | |
} | |
public load() { | |
const promise = this.http.get(this.configUrl).toPromise(); | |
promise.then((data: any) => (this._config = data)); | |
return promise; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment