I have main AppRoutingModule
class where I set my routes and add in my appModule
:
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'shopCart', component: ShopCartComponent },
{ path: 'administration', loadChildren: './admin/admin.module#AdminModule' },
{ path: 'productsList', loadChildren: './products/products.module#ProductsModule' },
{ path: 'not-found', component: PageNotFoundComponent, data: { message: 'Page not found!' } },
{ path: '**', redirectTo: '/not-found' }
];
@NgModule({
imports: [RouterModule.forRoot(appRoutes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule { }
In appModule
I am add in imports module
ModalModule.forRoot(),
NgbModule.forRoot(),
And in providers
I am add NgbActiveModal
.
I want to lazy load admin.module
and in this module I have modal
.
My admin.module is :
@NgModule({
imports: [
CommonModule,
ReactiveFormsModule,
FormsModule,
AdminRoutingModule,
NgbModule,
AlertModule.forRoot()
],
declarations: [
AdminComponent,
CategoryComponent,
ProductModal
]
, entryComponents: [
CategoryComponent,
ProductModal
]
})
export class AdminModule { }
All work good and that I click on the my modal I click on the modal, I have error :
ERROR Error: No component factory found for CategoryComponent. Did you add it to @NgModule.entryComponents?
I followed this link link
I want to mention, everything was working good before Lazy loading.