Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!