Skip to content

Instantly share code, notes, and snippets.

@chaosmonster
Created August 23, 2022 13:27
Show Gist options
  • Save chaosmonster/675b6e99816819e0c01ac258cda4e7ec to your computer and use it in GitHub Desktop.
Save chaosmonster/675b6e99816819e0c01ac258cda4e7ec to your computer and use it in GitHub Desktop.
// belongs to SpecialModule which is a generic lib, every App needs to provide their implementation of UserService.
// The lib uses this special implementation as UserService internally
abstract class UserService {
}
@Injectable()
class SpecialService {
constructer(private userService: UserService) {}
}
@NgModule({
imports: [SpecialModule],
providers: [
SpecialService
]
})
SpecialModule ()
@NgModule({
imports: [SpecialModule],
providers: [
{
provide UserService,
useClass: ConcreteUserService,
}
]
})
AppModule()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment