I have an index.html file and in it I have a script tag that's receiving a callback from google maps. If I remove the timeout, I get this error.
Uncaught TypeError TypeError: window.globalMethod is not a function
My 'globalMethod' is located in a directive being used on the page and I would assume maybe the directive's constructor isn't loaded, but I'm running the google maps script after <app-root></app-root> so you would think it would find window.globalMethod()?
I tried it with 100, but that doesn't seem to be long enough and still receive the error.
Here is index.html
<!doctype html>
<html lang="en">
<head>
// left out other head tags for brevity
<script>
function initPlaces() {
// won't run if I remove window.setTimeout
window.setTimeout(() => {
window.globalMethod();
}, 1000);
}
</script>
</head>
<body>
<app-root></app-root>
<script src="https://maps.googleapis.com/maps/api/js?key=secret-key&libraries=places&callback=initPlaces" type="text/javascript"></script>
</body>
</html>