#Providing a service in a service
1 messages · Page 1 of 1 (latest)
I just provide it normally
@Component({
selector: 'parent-component',
template: '<name-component></name-component>,
providers: [ MainStoreService, SubComponent1Service, SubComponent2Service ...]
})
instead of providing it here, you can provide them in the Module where this component is declared
if the component is standalone you can provide them in the routing for those components
I suspect if you put sub services inside the main one you will still get an exception that they are not being provided anywhere so this is not the fix
or just declare them as providedIn: 'root' so that you never need to provide them anywhere
i cannot provide it in the module since I need a different instance for each instance of name-component
this works already btw. what I was looking for is to somehow provide main service and the subcomponent services together so im sure they are always provided together