angular - ngmodule 不是子类型 ngmoduletype

标签 angular angular-routing angular9 angular-module

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

相关文章:

json - 无法读取未定义的 Angular2 的属性 'getKey'

angular - 正确指定 tslint 包的路径

angular - 如何使用 Firebase 功能部署 Angular 9 通用应用程序

typescript - 迁移失败 : Incompatible peer dependencies found

angular - Angular 9 中模板必须是字符串错误

javascript - webpack + Angular 2 (rc5) - 组件未在生产版本中渲染

Angular 2 Dart : How to detect click on everything but element?

angular - 如何在模态窗口 [ANGULAR 5] 内创建路由?

Angular 6 - 如何根据变量的值注册不同的路由

尽管 `runGuardsAndResolvers` 设置为 'always',但 Angular 解析器未更新或重新获取数据?