Skip to content

Instantly share code, notes, and snippets.

@rakshitshah94
Last active June 7, 2022 04:08
Show Gist options
  • Save rakshitshah94/dcb199e7f63d2dc398a56daa87a59bcd to your computer and use it in GitHub Desktop.
Save rakshitshah94/dcb199e7f63d2dc398a56daa87a59bcd to your computer and use it in GitHub Desktop.
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