我有主要AppRoutingModule
课程,我在其中设置路线并添加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 { }
在appModule
我添加导入模块
ModalModule.forRoot(),
NgbModule.forRoot(),
在providers
我添加NgbActiveModal
。我想延迟加载admin.module
,在这个模块中我有modal
.
我的 admin.module 是:
@NgModule({
imports: [
CommonModule,
ReactiveFormsModule,
FormsModule,
AdminRoutingModule,
NgbModule,
AlertModule.forRoot()
],
declarations: [
AdminComponent,
CategoryComponent,
ProductModal
]
, entryComponents: [
CategoryComponent,
ProductModal
]
})
export class AdminModule { }
一切正常,我点击我的模态我点击模态,我有错误:
ERROR Error: No component factory found for CategoryComponent. Did you add it to @NgModule.entryComponents?
我跟着这个链接链接
我想提一下,在延迟加载之前一切都运行良好。