0

I have a JS file imported with script tags in my index.html. I need to call a file.init() function when the page renders. There are three different functions which load depending on the page, so I can't load it via script tags.

Does anyone know how I can call a function from this file? (it is es5) I'm ok with a hacky solution as I will eventually rewrite the whole thing (over 5000 lines) following angular 2 conventions.

Sam Chapman
  • 19
  • 1
  • 5

1 Answers1

0
import { Component, OnInit } from '@angular/core'
declare var myFunction.index.init:any

@Component({...})

export class MyComponent {
  myFunction.index.init:any

  constructor() {...}

  ngOnInit() {
    myFunction.index.init();
  }
}
Sam Chapman
  • 19
  • 1
  • 5