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

328
Visualizações
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 à 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