Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

91
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!