It is possible to restrict service provider scope to a specific module instead making available to entire application. There are two possible ways to do it.
import { Injectable } from '@angular/core'; import { SomeModule } from './some.module'; @Injectable({ providedIn: SomeModule, }) export class SomeService { }
import { NgModule } from '@angular/core'; import { SomeService } from './some.service'; @NgModule({ providers: [SomeService], }) export class SomeModule { }