gpt4 book ai didi

angular - ngmodule 不是子类型 ngmoduletype

转载 作者:行者123 更新时间:2023-12-03 14:42:34 24 4
gpt4 key购买 nike

我使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com