I have this code below where I’m loading google maps API and I want to issue a callback when loaded to instantiate some other stuff in another component.
How can I call a component from this initMap()?
I tried adding this code below in my app.component.ts file in the ngOnInit method but it wasn’t called.
window[‘initMap’] = function() {…}
This code below is my index.html file for an Angular application.
// index.html
<script>
function initMap() {
// call component here
console.log('test');
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=my-secret-key&libraries=places&callback=initMap" type="text/javascript"></script>