I am new to Angular2. I am looking for way to access windows environment variable in my angular 2 app. I have a env.js file which has below URLs.-
(function (window) {
window.__env = window.__env || {};
window.__env.previewUrl = 'http://localhost:3000/';
window.__env.workflowUrl = 'http://localhost:1337';
window.__env.baseUrl = '/';
}(this));
I need to access the this variable in my angular 2 component but it gives error that _env does not exist on type window.
this._http.get( window.__env.workflowUrl + this.swaggerDefSplit[1] + queryString1)
.map(res => res.json())
.subscribe(data => {
console.log(data);
if (!(data.Results instanceof Array)) {
// puts a single json object into array for *ngFor
data.Results = JSON.parse(JSON.stringify([data.Results]));
}
Thanks for help.