I can successfully inject TestService into CertService When I use CertModule provider, such as:
@NgModule({
declarations: [
],
imports: [
],
providers: [
CertService,
TestService
],
exports: [CertComponent],
bootstrap: [CertComponent]
})
But I want to limit the scope of TestService within CertComponent. So my purpose is to move the provider from CertModule to CertComponent. such as:
@Component({
selector: 'cert-component',
templateUrl: 'cert.component.html',
styleUrls: ['cert.component.scss'],
providers: [
TestService
]
})
But I find If I do this, will face a problem:
taticInjectorError(AppModule)[CertService -> TestService]:
Comments
Post a Comment