Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

300
Vistas
For Angular 8 - cannot loadChildren of type function via NgModuleFactoryLoader.load(path: string)

I have upgraded from Angular 7 to Angular 8 and I have changed the type of loadChildren from String to Function:

export interface DynamicComponentManifest {
componentId: string;
path: string;
loadChildren: Function;

}

And now when I am trying to load the loadChildren via NgModuleFactoryLoader load method like this:

public getComponentFactory<T>(
componentId: string,
injector?: Injector,
): Observable<ComponentFactory<T>> {
const manifest = this.manifests.find(m => m.componentId === componentId);
if (!manifest) {
  return throwError(`DynamicComponentLoader: Unknown componentId "${componentId}"`);
}

const p = this.loader.load(manifest.loadChildren).then(ngModuleFactory => {
  const moduleRef = ngModuleFactory.create(injector || this.injector);
  const dynamicComponentType = moduleRef.injector.get(DYNAMIC_COMPONENT);
  if (!dynamicComponentType) {
    throw new Error(
      oneLine`DynamicComponentLoader: Dynamic module for componentId "${componentId}"
         does not contain DYNAMIC_COMPONENT as a provider.`,
    );
  }

  return moduleRef.componentFactoryResolver.resolveComponentFactory<T>(dynamicComponentType);
});

I am getting an error at this line:

const p = this.loader.load(manifest.loadChildren).then(ngModuleFactory => {

The error: Argument of type 'Function' is not assignable to parameter of type 'string'

How should I rearrange the code or fix the code?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda