我有一个共享模块,希望在新的Angular应用中使用。 该共享使用了一个简单的服务,该服务执行发布请求,并且还包含来自同一共享模块的一组其他组件。
在我的新AppModule中导入模块,会产生以下错误:
StaticInjectorError(Platform: core)[UpgradeModule -> Injector]:
NullInjectorError: No provider for Injector!
at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:8895)
at resolveToken (core.js:9140)
at tryResolveToken (core.js:9084)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8981)
at resolveToken (core.js:9140)
at tryResolveToken (core.js:9084)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8981)
at resolveNgModuleDep (core.js:21217)
at _createClass (core.js:21264)
at _createProviderInstance (core.js:21234)
我感觉共享模块有问题,有人可以帮助我了解我的错吗?谢谢
我的“共享模块”
@NgModule({
declarations: [MyListComponent],
exports: [MyListComponent],
bootstrap: [MyListComponent],
imports: [
CommonModule, TranslateModule, FormsModule, NgbModule, SomeModule1, SomeModule2
],
providers: [MyListService]
})
export class MyListModule {
}
我的AppModule:
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
CommonModule,
MyListWrapperModule
],
providers: [
],
bootstrap: [AppComponent],
})
export class AppModule { }
我的包装器模块:
@NgModule({
declarations: [MyListWrapperComponent],
imports: [MyListModule],
exports: [MyListWrapperComponent]
})
export class MyListWrapperModule {
}