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

92
Vistas
Angular import external js in scoped component

I'm importing a .js file to my component with scriptjs and the following code:

declare var externalclass: any;

...

get('http://example.com/path/file.js', () => {
   const myclass = new externalclass();
   myclass.myfunction();
});

This way, I can call the function myfunction() from the class externalclass of the loaded file. This works fine, but there are multiple instances of the component and depending on other data the component loads other scripts e.g. file2.js, but every file has the same named class externalclass. After all components are loaded, the last loaded file gets used for all components.

Is there a way, to load the .js file but scope it to the component, so that only that specific component can access it, and there are no class name overlaps with other components?

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