title: Angular 2: import external js file into component
body: <p>I'm going to import this <a href="https://github.com/oliverbinns/d3gauge">d3gauge.js</a> file into one of my angular2 component, <code>memmon.component.ts</code> file. </p>
  
  <pre><code>import '../../../../js/d3gauge.js';
  export class MemMonComponent {
      createMemGauge() {
          new drawGauge(this.opt);  //drawGauge() is a function inside d3gauge.js
      }
  }
  </code></pre>
  
  <p>and in the corresponding template file, add </p>
  
  <pre><code>&lt;script src="../../../../js/d3gauge.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>But it doesn't work, <code>drawGauge</code>can't be found. </p>
  
  <p>So, </p>
  
  <ol>
  <li>what're correct steps to import an external js file to angular2? </li>
  <li>since I'm using webpack, is it possible to do it in webpack? I refer to this <a href="https://stackoverflow.com/questions/34489916/load-external-js-script-dynamically-in-angular-2">question</a> , the webpack solution there doesn't work for me as a result of <code>.ensure</code> can't be resolved.</li>
  </ol>