I have a simple class,
class TestClass {
init() {
this.loadGoogle();
}
initializeSearch() {
alert("here");
}
loadGoogle() {
const script = document.createElement('script');
script.src = 'https://maps.googleapis.com/maps/api/js?key={MY_KEY}&libraries=places&callback=initMap';
script.async = true;
window.initMap = () => {
//JS API IS LOADED
this.initializeSearch();
};
document.head.append(script);
}
}
I am having trouoble calling the intializeSearch method when the callback is fired. I am assuming it’s because this
is out of scope? Can I bring this into the scope of the window global?