title: How to call javascript on angular 2
body: <p>I have javascript file from assets/js/chartrank.js</p>
  
  <p><strong>chartrank.js</strong></p>
  
  <pre><code>function chartRank() {
      // do something
  }
  </code></pre>
  
  <p>and call a function defined in it on <code>rankuser</code> component but it doesn't work.</p>
  
  <p><strong>rankuser.component.ts</strong></p>
  
  <pre><code>import { Component, OnInit, AfterViewInit } from '@angular/core';
  import "../../assets/js/chartrank.js";
  declare var jsObject: any;
  
  @Component({
    selector: 'app-rankuser',
    templateUrl: './rankuser.component.html',
    styleUrls: ['./rankuser.component.css']
  })
  export class RankuserComponent implements OnInit, AfterViewInit {
  
    constructor() { }
  
    ngAfterViewInit() {
      jsObject.chartRank();
    }
  
    ngOnInit() {
  
    }
  }
  </code></pre>
  
  <p><strong>ERROR</strong> </p>
  
  <pre><code>ERROR ReferenceError: jsObject is not defined
  </code></pre>
  
  <p>Please help.</p>