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

784
Vistas
Angular Routing using navigation - children and loadChildren cannot be used together

My Main component template looks like this:

<app-navigation></app-navigation>

<div class="container-fluid">
  <router-outlet></router-outlet>
</div>

And this is the navigation:

   <div >
  <a routerLink="/home" routerLinkActive="active" >Home</a>
  <a  routerLink="/doctors" routerLinkActive="active" >
    Doctors
  </a>
  <a  routerLink="/health" routerLinkActive="active" >
    Health
  </a>
</div>

app.routing.ts

export const appRoutes: Routes = [

  {
    path: 'doctors',
    loadChildren: () => import('./doctore/doctore.module').then(m => m.DoctoreModule)
  },
  {
    path: 'health',
    loadChildren: () => import('./health/health.module').then(m => m.HealthModule),
  },
  {
    path: '**',
    component: NotFoundPageComponent
  }
];

Doctors components has a list of doctors, and upon selecting one of them, the app should route to a child component DoctorDetailsComponent, with path doctors/{id}

     <mat-cell [routerLink]="['/doctors', row.id]" routerLinkActive="active">
            {{row.description}} </mat-cell>

If I set the routing to be like this:

  {
    path: 'doctors',
    loadChildren: () => import('./docspace/docspace.module').then(m => m.DocspaceModule),
    children: [{path: ':id', component: DoctorsDetailsComponent}]   
  },

I get an error:

Invalid configuration of route 'doctors': children and loadChildren cannot be used together

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

If DoctorsDetailsComponent is inside DocspaceModule Then

{
    path: 'doctors',
    loadChildren: () => import('./docspace/docspace.module').then(m => m.DocspaceModule),   
  },

and in DocspaceRoutingModule

 const routes: Routes = [
   {
     path: '',
     component: DoctorSpaceComponent,
     children: [
       { path: '', redirectTo: ':id', pathMatch: 'full' } 
       { path: ':id', component: DoctorsDetailsComponent }
     ]
   }
 ];

DoctorSpaceComponent.html

    <router-outlet></router-outlet>
over 4 years ago · Santiago Trujillo Denunciar

0

I Handled it in the specific module routing ts.

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