Skip to content

"No NgModule metadata found" for lazy loaded module #24

@lexigren

Description

@lexigren

I'm trying to lazy load module Products
app.states.ts:

{
    name: 'Products',
    url: '/products',
    lazyLoad: loadProductsModule
  }

lazy.modules.ts:

export function loadProductsModule() {
  return loadNgModule(function () {
    return System.import('./views/products/products.module')
      .then(result => {
        return result.ProductsModule;
      });
  }, ExtraModuleInjector.injector);
}

0.chunk.js getting loaded successfully and System.import is getting resolved with object containing ProductsModule.

But next I'm getting an error: "No NgModule metadata found for '[object Object]"
With native router lazy load of same module works normally.

Could it be because of wrong scoped injector?

loadNgModule Gets the Injector (scoped properly for the destination state)

This one I'm getting from app.component from app module.
If I can't use this one, where should I take correct one? I couldn't find answer in docs.
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions