[英]Angular Pass HttpClient from app.module to another module to a service
[英]Angular pass a component from a module to another module in the App module
我在解决如何从导入到Angular应用程序中的模块传递组件并将其在我也导入到App中的另一个模块中使用时遇到问题。
请注意,所有这两个模块都是我创建的模块。
那就是我的app.module.ts:
@NgModule({
declarations: [
AppComponent,
HomeComponent,
PnDashboardComponent,
PnFormulaireComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
LayoutModule.forRoot(environment.layout),
DispoModule.forRoot(environment.dispoAides)
],
providers: [
ErrorsHandler,
InitialisationService,
InitializationGuard
],
bootstrap: [AppComponent]
})
我想要做的是将一个名为BreadcrumbComponent
的组件从LayoutModule
到DispoModule
并DispoModule
能够在该模块内使用它。
请注意,LayoutModule和DispoModule是依赖的角度模块项目,与ng-packagr打包在一起并导入到我的应用程序中。
谢谢。
您需要创建一个SharedModule
并在其中声明BreadcrumbComponent
。 还导出组件,以便我可以在其他模块中使用。
导入要在应用程序中使用BreadcrumbComponent的任何位置的SharedModule
如果您想做的就是将一个名为BreadcrumbComponent
的组件从LayoutModule
到DispoModule
,并且可以在该模块中使用它。
然后写
exports: [
BreadcrumbComponent
]
在您的LayoutModule
进口LayoutModule
在DispoModule
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.