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

205
Views
Angular: quiero dividir un servicio en varios servicios pero compartir los mismos datos

Tengo un servicio que tiene 1000 líneas, me gustaría dividirlo en varios servicios pero necesito compartir algunos datos entre estos diferentes servicios.

 @Injectable() export class ServiceParent { toto = new Toto(), } @Injectable() export class ServiceChild extend ServiceParent { init() { this.toto.doSomething(); } } @Component() export class myComponent { ngOnInit() { console.log('this.ServiceChild.init()') // return undefined } }

Cómo resolver este problema ?

gracias ^^

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simplemente cree una variable global.

 let toto = new Toto(); @Injectable() export class Service1 { init() { this.toto.doSomething(); } } @Injectable() export class Service2 { init() { this.toto.doSomething(); } }
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!