Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

310
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda