我使用 angular 9,我想做延迟加载,我做 app-routing
{
path: '', loadChildren: () => import("./components/login/login.module")//.then(m =>
// m.LoginModule)
}
在我创建登录模块之后:
@NgModule({
declarations: [LoginComponent],
imports: [
CommonModule,
FormsModule,
LoginModuleRouting
],
providers:[]
})
export class LoginModule { }
和路由:
const routes: Routes = [
{
path: '', component: LoginComponent,
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class LoginModuleRouting { }
问题是当我调用
ng serve
然后我继续` http://localhost:4200/ ,我得到这个异常:核心.js:6237
ERROR Error: Uncaught (in promise): Error: ASSERTION ERROR: NgModule '[object Module]' is not a subtype of 'NgModuleType'. [Expected=> null != null <=Actual]
Error: ASSERTION ERROR: NgModule '[object Module]' is not a subtype of 'NgModuleType'. [Expected=> null != null <=Actual]
我不知道这是什么意思。任何人都可以帮助我吗?
最佳答案
我不知道为什么,但您在 loadChildren() 上注释掉了您的登录模块:
{
path: '',
loadChildren: () => import("./components/login/login.module")//.then(m =>
// m.LoginModule)
}
它应该是:{
path: '',
loadChildren: () => import("./components/login/login.module").then(m => m.LoginModule)
}
关于angular - ngmodule 不是子类型 ngmoduletype,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61614664/