Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
Global method not being called unless I have a window.setTimeout of 1000 ms around the call

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>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda