Skip to content

Instantly share code, notes, and snippets.

@whisher
Last active January 26, 2019 19:38
Show Gist options
  • Save whisher/3605d55e561bc6a37a78243fd436dd0b to your computer and use it in GitHub Desktop.
Save whisher/3605d55e561bc6a37a78243fd436dd0b to your computer and use it in GitHub Desktop.
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