Skip to content

Instantly share code, notes, and snippets.

@alxhub
Last active April 6, 2018 20:31
Show Gist options
  • Save alxhub/6ff284dc38da77732b793740b908e0b4 to your computer and use it in GitHub Desktop.
Save alxhub/6ff284dc38da77732b793740b908e0b4 to your computer and use it in GitHub Desktop.
@Injectable({
providedIn: 'root',
useClass: ServiceClientImpl,
})
class AbstractService {
static ngInjectableDef = {
factory: () => new ServiceClientImpl(inject(Dep)),
providedIn: 'root',
};
}
@Injectable()
class ServiceClientImpl implements AbstractService {
...
}
// other module
@Injectable()
class ServiceServerImpl implements AbstractService {
...
}
@NgModule({
providers: [{provide: AbstractService, useClass: ServiceServerImpl}],
})
class ServiceServerModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment