title: How to access windows environment variables in angular2 JS app
body: <p>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.- </p>
  
  <pre><code>(function (window) {
    window.__env = window.__env || {};
     window.__env.previewUrl = 'http://localhost:3000/';
    window.__env.workflowUrl = 'http://localhost:1337';
    window.__env.baseUrl = '/';
  }(this));
  </code></pre>
  
  <p>I need to access the this variable in my angular 2 component but it gives error that _env does not exist on type window. </p>
  
  <pre><code> this._http.get( window.__env.workflowUrl + this.swaggerDefSplit[1] + queryString1)
              .map(res =&gt; res.json())
              .subscribe(data =&gt; {
                  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]));
  
  
                  }
  </code></pre>
  
  <p>Thanks for help. </p>