Reputation: 1414
I have created a global env variable called env.js
which I can use outside angular, however I want to use the same env variable in angular2.
(function (window) {
window.__env = window.__env || {};
window.__env.baseUrl= 'http://www.examplesite.com/1';
window.__env.otherUrl = 'http://www.examplesite.com/2';
window.__env.baseUrl = '/';
}(this));
however when I use window.__env.baseUrl
it gives me an error of .__env.baseUrl
does not exist on type Window
. So just wondering how can I import Window
so it'd allow me to use .__env.baseUrl
.
Upvotes: 0
Views: 206
Reputation: 6813
That's because the compiler checks the type, and it only knows the "common" properties of the window object.
You can "use" global variables like this:
declare var xxx: any;
export class .... {
}
In your case it would be:
declare var __env: any;
Upvotes: 2