Accessing Global JS Variable


#1

I am trying to access a global JS variable. When I console out the global window variable (in the example below) I can see the variable I am trying to access in the logged object.

constructor(public navCtrl: NavController) {
    console.log(window);
}

When I try to select the variable, it says the variable cannot be found.

constructor(public navCtrl: NavController) {
    console.log(window.someVar);
}

Thanks, any help is appreciated.


#2

This is extremely unidiomatic for Angular applications. Can’t you use a service provider instead of polluting window?


#3

Thanks for your response!

I agree that would be much better solution. I am trying to get WaveSurfer.js to work in Ionic 3 and not having any luck. I am not sure how else to get it to work without accessing the WaveSurfer variable.

WaveSurfer did just come out with ES6 support but I havent been able to get that to work either.