xanx2323
xanx2323

Reputation: 11

Lazy Singleton-Service in multiple lazy modules

I have a Service which I would like to provide to 2 Lazy Modules - but not for the whole application.

I'm Providing the Service through a Module with the forRoot(): ModuleWithProviders convention into those 2 Lazy Modules - which leads to 2 Instances of the Service. If I would use forRoot in app.module I could use forChild in the lazy Modules but then the Service is loaded for the whole application.

Is it possible to only load the Service for Lazy Modules and still have it as a Singleton?

Upvotes: 1

Views: 390

Answers (1)

Maybe you can create a tree of modules. Create a lazy module that contains the service and the other two lazy modules. Although I personally would put the service and leave it in a shared module.

Upvotes: 0

Related Questions