Last active
June 7, 2022 04:08
-
-
Save rakshitshah94/dcb199e7f63d2dc398a56daa87a59bcd 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 { HttpClient } from '@angular/common/http'; | |
import { Injectable } from '@angular/core'; | |
import { map } from 'rxjs/operators'; | |
import { AppConstants } from './appConstants'; | |
@Injectable() | |
export class AppConfig { | |
public static config: Object = null;// <-- Your global config variable | |
constructor(private http: HttpClient) { | |
} | |
public getConfig(key: any) { | |
if(AppConfig.config && AppConfig.config[key]){ | |
return AppConfig.config[key]; | |
} | |
else{ | |
return null; | |
} | |
} | |
public load() { | |
this.http.get('assets/config/globalconfig.json').pipe(map(data => { | |
return data; | |
})).subscribe((data) => { | |
AppConfig.config = data; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment