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

156
Vistas
how to load two JS files returning same global variable in Angular 10

Hello guys I have 2 JS files which returns window Object. but when I load these two files in angular the first js file is getting overridden by second js file due to global object.

Below are the Scripts

script1

public createFirstScript() {
let scriptsArray = ["firstUrl"]
for (let scriptIn of scriptsArray) {
const script = document.createElement('script');
script.setAttribute('id', scriptIn);
script.crossOrigin = 'anonymous';
let lang =  'en';
script.src = environment.service[scriptIn][lang];
document.head.appendChild(script);
}
}

script returns window object which needs to be loaded to get dynamic data which

returns (window).data


script2

public createSecondScript() {
let scriptsArray = ["secondUrl"]
for (let scriptIn of scriptsArray) {
const script = document.createElement('script');
script.setAttribute('id', scriptIn);
script.crossOrigin = 'anonymous';
let lang =  'en';
script.src = environment.service[scriptIn][lang];
document.head.appendChild(script);
}
}

script returns window object which needs to be loaded to get dynamic data which returns (window).data

when these two scripts are loaded in angular the first Script is getting overridden by second script

Am loading this scripts when app is initialized. Both of these script data needs to be rendered on same route

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