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 ^^
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(); } }