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

329
Vistas
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
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