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

384
Views
Call Service inside ngdobootstrap

I am creating application using angular and calling api call inside the ngdobootrap method. I am getting error while injecting the service inside bootstrap:

export class AppModule {
    constructor(private upgrade: UpgradeModule, private router: Router, private location: Location,private services : someservice) { }
    ngDoBootstrap(moduleRef) {
      this.getdata()
    }
    getdata() {
      this.services.data().subscribe((res: any) => {
       console.log(res)
      }, error => {
       
      })
    }

Error:

zone.js:682 Unhandled Promise rejection: Trying to get the AngularJS injector before it being set. ; Zone: <root> ; Task: Promise.then ; Value: Error: Trying to get the AngularJS injector before it being set.
    at injectorFactory (vendor.js:148805:15)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Add the forwardRef to the service in the constructor,

@Inject(forwardRef(() => 'someservice')) private services : someservice

There is more detail here

about 4 years ago · Juan Pablo Isaza Report
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!