#Is it possible to provide service into component?

2 messages · Page 1 of 1 (latest)

rigid barn
#

I have a service called TableHelperService. This service is used by other component services. TableHelperService can not be a singleton, each use of it by another service needs it's own copy. I can not provide TableHelperService this at the routing module level since it would be a singleton. Is it possible to import TableHelperService into the component itself? And if so, what about FooService which uses TableHelperService... will that need to be imported into the component as well?

https://dpaste.org/p2Lnr

analog egret
#

If you try to inject this component-level service into a root-level service, that won't work since the root-level service is not created by the component injector and is a singleton. So either all the other services are also provided on the component, or you somehow pass this component-level service as argument to the root-level service methods.