title: How to call a onload function inside javascript in Angular 6?
body: <p>I am importing a jquery game to my ionic app version 4 which is based on Angular 6. I am able to import all the required js and css files to angular.
  But as the game starts using </p>
  
  <blockquote>
    <p>game.onload()</p>
  </blockquote>
  
  <p>in windows.load function, the same i tried in ngInit() in Angular 6. But its not working! How could i call a function which is defined iniside a variable in javascript using Angular 6.</p>
  
  <p>My JS code is:</p>
  
  <pre><code>var game = {
      data: {
          score: 0,
          steps: 0,
          start: !1,
          newHiScore: !1,
          muted: !1
      },
      resources: [{
          name: "bg",
          type: "image",
          src: "../data/img/bg.png"
      }, {
          name: "clumsy",
          type: "image",
          src: "../data/img/clumsy.png"
      }, {
          name: "pipe",
          type: "image",
          src: "../data/img/pipe.png"
      }, {
          name: "logo",
          type: "image",
          src: "../data/img/logo.png"
      }, {
          name: "ground",
          type: "image",
          src: "../data/img/ground.png"
      }, {
          name: "gameover",
          type: "image",
          src: "../data/img/gameover.png"
      }, {
          name: "gameoverbg",
          type: "image",
          src: "../data/img/gameoverbg.png"
      }, {
          name: "hit",
          type: "image",
          src: "../data/img/hit.png"
      }, {
          name: "getready",
          type: "image",
          src: "../data/img/getready.png"
      }, {
          name: "new",
          type: "image",
          src: "../data/img/new.png"
      }, {
          name: "share",
          type: "image",
          src: "../data/img/share.png"
      }, {
          name: "tweet",
          type: "image",
          src: "../data/img/tweet.png"
      }, {
          name: "theme",
          type: "audio",
          src: "../data/bgm/"
      }, {
          name: "hit",
          type: "audio",
          src: "../data/sfx/"
      }, {
          name: "lose",
          type: "audio",
          src: "../data/sfx/"
      }, {
          name: "wing",
          type: "audio",
          src: "../data/sfx/"
      }],
      onload: function() {
          return me.video.init(900, 600, {
              wrapper: "screen",
              scale: "auto",
              scaleMethod: "fit"
          }) ? (me.audio.init("mp3,ogg"), void me.loader.preload(game.resources, this.loaded.bind(this))) : void alert("Your browser does not support HTML5 canvas.")
      },
      loaded: function() {
          me.state.set(me.state.MENU, new game.TitleScreen), me.state.set(me.state.PLAY, new game.PlayScreen), me.state.set(me.state.GAME_OVER, new game.GameOverScreen), me.input.bindKey(me.input.KEY.SPACE, "fly", !0), me.input.bindKey(me.input.KEY.M, "mute", !0), me.input.bindPointer(me.input.KEY.SPACE), me.pool.register("clumsy", game.BirdEntity), me.pool.register("pipe", game.PipeEntity, !0), me.pool.register("hit", game.HitEntity, !0), me.pool.register("ground", game.Ground, !0), me.state.change(me.state.MENU)
      }
  }; 
  </code></pre>
  
  <p>I want to call onload function inside game variable!</p>
  
  <p>My Angular Code is:</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { NavParams  } from '@ionic/angular';
  import { ActivatedRoute } from '@angular/router';
  //declare function helloJS();
  @Component({
    selector: 'app-test',
    templateUrl: './test.page.html',
    styleUrls: ['./test.page.scss'],
  })
  export class TestPage implements OnInit {
    id: string
    constructor(private route : ActivatedRoute) { 
  
    }
  
    ngOnInit() {
      game.onload();
    }
  }
  </code></pre>
  
  <p>i tried by above code! But error is <code>cannot find name game</code>. I know that its usual as angular cant get what game is! SO how could i call that function!
  Please help me!</p>