Skip to content

Instantly share code, notes, and snippets.

@guillefd
Created May 17, 2019 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillefd/f4be5dd23d68332d17c54f2fed7b2caf to your computer and use it in GitHub Desktop.
Save guillefd/f4be5dd23d68332d17c54f2fed7b2caf to your computer and use it in GitHub Desktop.
Import JSON in Angular
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import jsonCfg from '../../../data/config.json';
@Injectable()
export class AppCfg {
constructor(private http: HttpClient) {}
load(): Promise<void> {
return new Promise<void>((resolve, reject) => {
const jsonFile = <unknown>jsonCfg;
this.customCfg = <any>lokalumJsonFile;
console.log(`[CFG_LOADED]`);
resolve();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment