title: Plain Javascript as Angular 2 service
body: <p>I need to add a hosted third-party JavaScript file in an Angular 2 component.  This file is updated anytime a change is made in the associated third-party vendors proprietary system, so I cannot simply pull down a copy, include it locally, and import it into the project.</p>
  
  <p>Typically I would include this file at a top level in a script tag, and then simply use <code>declare &lt;windowvar&gt;: any</code> to get access to it.  However in this case, since the component itself is trying to load the script, I cannot declare the window variable because it does not exist on the window object at the time the component is loaded, which generates an error.</p>
  
  <p>I can load the script by manually adding a script tag, and that works, however I need access to the window variable it creates in order to use it properly.  And I cannot simply use an interval to look for it because typescript throws a fit that <code>&lt;windowvariable&gt; does not exist on object window</code>.</p>
  
  <p>Is there any way I can 1) Load the hosted JavaScript file inside the component, and 2) Get access to the window variable created by the loaded JavaScript file?</p>