From 8733ac0770aab10231b59d0398acd33765936247 Mon Sep 17 00:00:00 2001 From: Danijel Anđelković Date: Thu, 14 Apr 2022 00:16:50 +0200 Subject: Dodao servis za citanje konfiguracije tako da moze da se promeni u buildovanoj angular aplikaciji. --- frontend/src/app/configuration.service.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 frontend/src/app/configuration.service.ts (limited to 'frontend/src/app/configuration.service.ts') diff --git a/frontend/src/app/configuration.service.ts b/frontend/src/app/configuration.service.ts new file mode 100644 index 00000000..4d2b0987 --- /dev/null +++ b/frontend/src/app/configuration.service.ts @@ -0,0 +1,20 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { IConfig } from '../app/_data/IConfig' + +@Injectable() +export class Configuration { + static settings: IConfig; + constructor(private http: HttpClient) { } + load() { + const jsonFile = 'assets/config.json'; + return new Promise((resolve, reject) => { + this.http.get(jsonFile).toPromise().then((response) => { + Configuration.settings = response; + resolve(); + }).catch((response: any) => { + reject(`Could not load file '${jsonFile}': ${JSON.stringify(response)}`); + }); + }); + } +} \ No newline at end of file -- cgit v1.2.3