UNPKG

@ngx-config/http-loader

Version:

Loader for ngx-config that provides application settings using http

27 lines (24 loc) 1.04 kB
import { __decorate, __param, __metadata } from 'tslib'; import { HttpClient } from '@angular/common/http'; import { resolveForwardRef, Inject, forwardRef } from '@angular/core'; var ConfigHttpLoader = (function () { function ConfigHttpLoader(http, endpoint) { if (endpoint === void 0) { endpoint = '/config.json'; } this.http = http; this.endpoint = endpoint; } ConfigHttpLoader.prototype.loadSettings = function () { var _this = this; return new Promise(function (resolve, reject) { var http = resolveForwardRef(_this.http); http.get(_this.endpoint).subscribe(resolve, function () { return reject('Endpoint unreachable!'); }); }); }; ConfigHttpLoader = __decorate([ __param(0, Inject(forwardRef(function () { return HttpClient; }))), __metadata("design:paramtypes", [HttpClient, String]) ], ConfigHttpLoader); return ConfigHttpLoader; }()); export { ConfigHttpLoader }; //# sourceMappingURL=ngx-config-http-loader.js.map