I have an issue figuring out how I can pass a component from a module I import into my Angular application and use it inside another module that I import also in my App.
Note that all those two modules are modules I created.
That's my 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]
})
What I want to do is pass a component let's say called BreadcrumbComponent
from the LayoutModule
to the DispoModule
and beeing able to use it inside that module.
Note that LayoutModule and DispoModule are dependent angular module project that are packaged with ng-packagr and imported in my Application.
Thank you.
You need to create a SharedModule
and declare the BreadcrumbComponent
in it. Also export the component so that i can be used across other Modules.
Import the SharedModule wherever you want to use BreadcrumbComponent in the application
If you want to do is pass a component let's say called BreadcrumbComponent
from the LayoutModule
to the DispoModule
and beeing able to use it inside that module.
then write
exports: [
BreadcrumbComponent
]
in your LayoutModule
and import LayoutModule
in DispoModule
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.