I have two services, both @Injectable. ServiceA is provided to components through the Providers array and is ubiquitous. ServiceB is a singleton and is located in the Providers array of its module and works great everywhere. ServiceA should not remain anything, and ServiceB should remain single.
My problem is that now I need to access ServiceA from ServiceB, but I don’t know how to access it. It seems that I cannot enter non-single service into a singleton.
Everything that I encounter tells me that I have to put the service in bootstrap or in the module declaration, but, as I said, I can’t do this, because I need ServiceA to behave as not a single one.
// module setup
... providers: [ServiceB]
// non-singleton
@Injectable()
export class ServiceA
// singleton
@Injectable()
export class ServiceB {
constructor(ServiceA) // <-- this is the problem area, need to get ServiceA here
- (Inject (ServiceA) serviceA), ,
: DI ServiceA!
- "" , singleton, , @Injectable?