For now for each rout of my app I am loading exact module. Here is how I am doing that :
const routes: Routes = [
{
path: '',
loadChildren: './pages/site-index/site-index-routing.module#SiteIndexRoutingModule'
}
{
path: 'account',
loadChildren: './pages/site-account/site-account-routing.module#SiteAccountRoutingModule'
}
];
If I declare the following components : HeaderComponent, MenuComponent, FooterComponent in app.module.ts like that :
const BASE_COMPONENTS: any[] = [
HeaderComponent,
FooterComponent,
MenuComponent
];
@NgModule({
imports: [
BrowserModule,
AppRoutingModule
],
declarations: [
AppComponent,
...BASE_COMPONENTS
],
bootstrap: [ AppComponent ]
})
- My
SiteIndexComponentand the rest components which were lazy-loaded cry that they do not knowHeaderComponent, FooterComponent, MenuComponentand ask to declare them.
But!
If I declare HeaderComponent, FooterComponent, MenuComponent both in SiteIndexModule and SiteAccountModule - these cry that HeaderComponent, FooterComponent, MenuComponent were declared in two places and ask to declare in any module above containing SiteIndexModule and SiteAccountModule
P.S. If I declare HeaderComponent, FooterComponent, MenuComponent only in SiteIndexModule and do not use these by SiteAccountModule - everything is ok. The problem is only when I'd like to use HeaderComponent, FooterComponent, MenuComponent in several lazy-loaded modules.
How can I resolve my problem?
thanks