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

327
Views
Why do I get error when I try to return a string from a function in loadChildren in Angular?

For some reason I have to add the string '../home/home.module#HomeModule' to loadChildren, but how come a function that returns the same string does not work? I want to be able to concat the string based on some variables such as if it is going to be ahead of time compilation because then I can't do ../, I have to do ./ as the root path.

Any workaround for this?

function loadHome() {
    return '../home/home.module#HomeModule';
}

const mainRoutes: Routes = [
    {
        path: '',
        component: MainComponent,
        children: [
            { path: '', loadChildren: loadHome()}
        ]
    },
    { path: '**', redirectTo: '/' }
];

I am getting the error: EXCEPTION: Uncaught (in promise): Error: Cannot find module '../home/home.module'

over 4 years ago · Santiago Trujillo
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!