简体   繁体   English

找不到 [object Module] 的 ngmodule 元数据

[英]no ngmodule metadata found for [object Module]

I was reworking my routes by changing them from lazy loaded from a string reference into lazy loaded from a call to import .我正在修改我的路由,将它们从字符串引用的延迟加载更改为调用import的延迟加载。

My problem is, every time I navigate to one of the pages, I'm getting the following error message: No NgModule metadata found for '[object Module]'.我的问题是,每次我导航到其中一个页面时,我都会收到以下错误消息:No NgModule metadata found for '[object Module]'。

consolelogs.js:49 ERROR Error: Uncaught (in promise): Error: No NgModule metadata found for '[object Module]'.
Error: No NgModule metadata found for '[object Module]'.
    at NgModuleResolver.resolve (compiler.js:20665)
    at CompileMetadataResolver.getNgModuleMetadata (compiler.js:19794)
    at JitCompiler._loadModules (compiler.js:25582)
    at JitCompiler._compileModuleAndComponents (compiler.js:25565)
    at JitCompiler.compileModuleAsync (compiler.js:25527)
    at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:216)
    at MergeMapSubscriber.wrapIntoObservable.pipe.Object [as project] (router.js:5369)
    at MergeMapSubscriber._tryNext (mergeMap.js:46)
    at MergeMapSubscriber._next (mergeMap.js:36)
    at MergeMapSubscriber.next (Subscriber.js:49)
    at NgModuleResolver.resolve (compiler.js:20665)
    at CompileMetadataResolver.getNgModuleMetadata (compiler.js:19794)
    at JitCompiler._loadModules (compiler.js:25582)
    at JitCompiler._compileModuleAndComponents (compiler.js:25565)
    at JitCompiler.compileModuleAsync (compiler.js:25527)
    at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:216)
    at MergeMapSubscriber.wrapIntoObservable.pipe.Object [as project] (router.js:5369)
    at MergeMapSubscriber._tryNext (mergeMap.js:46)
    at MergeMapSubscriber._next (mergeMap.js:36)
    at MergeMapSubscriber.next (Subscriber.js:49)
    at resolvePromise (zone-evergreen.js:797)
    at resolvePromise (zone-evergreen.js:754)
    at zone.scheduleMicroTask (zone-evergreen.js:858)
    at ZoneDelegate.invokeTask (zone-evergreen.js:391)
    at Object.onInvokeTask (core.js:34182)
    at ZoneDelegate.invokeTask (zone-evergreen.js:390)
    at Zone.runTask (zone-evergreen.js:168)
    at drainMicroTaskQueue (zone-evergreen.js:559)
    at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:469)
    at invokeTask (zone-evergreen.js:1603)

What is causing this problem?是什么导致了这个问题?

It turns out, I was using lazy-loading for my routes but failed to correctly import the module of the page I was loading.事实证明,我为我的路线使用了延迟加载,但未能正确导入我正在加载的页面的模块。 Notice the missing call to then() .请注意对then()的缺失调用。

{
  path: "references",
  children: [
    {
      path: "",
      loadChildren: () =>
        import(
          "app/applications/requirements/requirements-references/requirements-references.module"
        ).then(m => m.RequirementsReferencesPageModule)
    },
    {
      path: ":referenceId",
      loadChildren: () =>
        import(
          "app/applications/requirements/requirements-references-detail/requirements-references-detail.module"
        )
    }
  ]
}

I missed the then part of the import.我错过了导入的then部分。 Remember to follow the following pattern:请记住遵循以下模式:

import("path-to-your-module").then(m => m.NameOfModule)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM