title: How to use external Javascript function in Angular 2 template?
body: <p>I have a template in the component with 4 div tags. The JavaScript function I want to call, <code>changeValue()</code>, is supposed to change the content of the first div from <code>1</code> to <code>Yes!</code>. I'm new to TypeScript and Angular 2, so I'm not sure how I can get the template to interact with the function from <code>dtest2.js</code>:</p>
  
  <pre><code> /**app.component.ts */
  
  import { Component } from '@angular/core';
  
  @Component({
  selector: 'my-app',
  template: `
    &lt;div id="boolean"&gt;&lt;p id="bv"&gt;1&lt;/p&gt;&lt;/div&gt;
    &lt;div id="numeric"&gt;&lt;p id="nv"&gt;2&lt;/p&gt;&lt;/div&gt; 
    &lt;div id="string"&gt;&lt;p id="sv"&gt;3&lt;/p&gt;&lt;/div&gt; 
    &lt;div id="enum"&gt;&lt;p id="ev"&gt;4&lt;/p&gt;&lt;/div&gt;
    `
  })
  
  export class AppComponent { }
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//dtest2.js
  
  function changeValue(){
    var newVal= "Yes!"; 
    document.getElementById("bv").innerHTML= newVal;
  }
  
  changeValue();</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Angular 2 QuickStart&lt;/title&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;link rel="stylesheet" href="styles.css"&gt;
  
      &lt;!-- Polyfill(s) for older browsers --&gt;
      &lt;script src="node_modules/core-js/client/shim.min.js"&gt;&lt;/script&gt;
  
      &lt;script src="node_modules/zone.js/dist/zone.js"&gt;&lt;/script&gt;
      &lt;script src="node_modules/reflect-metadata/Reflect.js"&gt;&lt;/script&gt;
      &lt;script src="node_modules/systemjs/dist/system.src.js"&gt;&lt;/script&gt;
      &lt;script src="file:^html/angular/app/bs.min.js"&gt;&lt;/script&gt;
      &lt;script src="file:^html/dtest2.js"&gt;&lt;/script&gt;
      
      &lt;script src="systemjs.config.js"&gt;&lt;/script&gt;
      &lt;script&gt;
        System.import('app').catch(function(err){ console.error(err); });
      &lt;/script&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
      &lt;my-app&gt;Loading...&lt;/my-app&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>