1

Im trying to work out what's the best way to achieve adding a singleton service to a 'core module' and consuming that service from a component within another module without creating a new instance of the service, as follows:

CoreModule ----- AppModule (imports CoreModule) ----- AppRoutingModule | | CacheService SubModule (loaded from AppRoutingModule with 'loadChildren:') | SubComponent (loaded from SubRoutingModule, needs to use CacheService)

Note: This is a little different to simply using a singleton service shared by components belonging to the AppModule as I would like sub-modules to also utilise that service. According to the docs Services aren't inherited through modules?

JonRowley
  • 68
  • 1
  • 7

0 Answers0