I want to use "window["initMapCallback"] to call and listen for "initMapCallback" in another file, but I'm getting an error in the debug window that says
Question - How do I correctly use this as "window["initMapCallback"] = function()" is not being triggered.
Uncaught (in promise) TypeError: window.initMapCallback is not a function at initMap ((index):35:32)
<script>
function initMap() {
window["initMapCallback"](); // error here!
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=secret-key&libraries=places&callback=initMap" type="text/javascript" async defer></script>
In the component where I want to listen and receive it I have this
ngOnInit() {
window["initMapCallback"] = function() {
console.log('listener entered');
};
}
If I remove the "()" from the call, there is no error but I still don't get the function to be called or entered into.