Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda