繁体   English   中英

NullInjectorError: R3InjectorError(AppModule)[MenuElementsDataService -> > MenuElementsDataService -> MenuElementsDataService]

[英]NullInjectorError: R3InjectorError(AppModule)[MenuElementsDataService -> > MenuElementsDataService -> MenuElementsDataService]

我已经声明了模块级服务,如下所示:

浏览.module.ts

@NgModule({
  imports: [BrowseRoutingModule, SharedModule, PrimengModule],
  declarations: [
    BrowseComponent,
    FirstMenuComponent,
   
  ],
  providers: [MenuElementsDataService],
})
export class BrowseModule {}

该服务在 Parent 组件上运行良好。 BrowseComponent 但是在嵌套的 Child 组件上给出了 Null Injector 错误。 FirstMenuComponent

你知道为什么吗?

core.js:6479 错误错误:未捕获(承诺):NullInjectorError:R3InjectorError(AppModule)[MenuElementsDataService -> MenuElementsDataService -> MenuElementsDataService]:
NullInjectorError: MenuElementsDataService 没有提供程序! NullInjectorError: R3InjectorError(AppModule)[MenuElementsDataService -> MenuElementsDataService -> MenuElementsDataService]: NullInjectorError: No provider for MenuElementsDataService!

该模块的组件树是这样的:

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM