Skip to main content

Angular - Usar Lazy loading a module that have different components BUT using the path of the parentun modulo que tiene componentes diferentes usando la ruta del padre

Publicación reabierta por Pikoh
Publicación cerrada como "No adecuado para este sitio" por Pablo Lozano, fedorqui, Mauricio Contreras, user22539, Pikoh
se añadieron 29 caracteres en el cuerpo
Origen Enlace

Dears,

I'm trying to lazy load a moduleEstoy tratando de cargar de forma diferida un módulo -> menu.module#MenuModulemodule # MenuModule

 construtas routesconstantes: RoutesRutas = [
         {
            pathcamino: '',
            loadChildren: './home/home.module#HomeModule'
        },   { pathruta: '**', loadChildren: './ menu.module#MenuModule'}module # MenuModule'}];

MenuModule hae other routestiene otras rutas

construtas routesconstantes: RoutesRutas = [
    { pathruta: 'hello', componentcomponente: HelloComponent , pathMatch:ruta 'full'de acceso: 'completo'},
{ pathruta: 'hello2', componentcomponente: Hello2Component , pathMatch: 'full' },
];

I need thatNecesito que hello andy hello2 be likesean como http://server/hello oro http://server/hello2 but it's always entering on home becuase the parent match withpero siempre entra en Home por la coincidencia con ''.

I don't want to put that routesNo quiero poner esas rutas (Hello andy hello2) on parent as I want both use a new module and I don't want to create a new route for each helloen padre, ya que quiero que ambos usen un nuevo módulo y no quiero crear una nueva ruta para cada 'hello'.

Do you have any clue how I can solve this¿Tienes alguna idea de cómo puedo resolver esto?

PD: This is an exampleEste es un ejemplo, theel proyecto real project has more routes on childtiene más rutas en el router hijo, that's why I don't want create a new route for each componentpor eso no quiero crear una nueva ruta para cada componente. I tried to useProbé de usar matcher but it's not working aspero no funciona ya que UrlSegment is always lengthsiempre tiene longitud 0

Thank youGracias

Dears,

I'm trying to lazy load a module -> menu.module#MenuModule

 const routes: Routes = [
         {
            path: '',
            loadChildren: './home/home.module#HomeModule'
        },   { path: '**', loadChildren:'./menu.module#MenuModule'} ];

MenuModule hae other routes

const routes: Routes = [
    { path: 'hello', component: HelloComponent , pathMatch: 'full' },
{ path: 'hello2', component: Hello2Component , pathMatch: 'full' },
];

I need that hello and hello2 be like http://server/hello or http://server/hello2 but it's always entering on home becuase the parent match with ''.

I don't want to put that routes (Hello and hello2) on parent as I want both use a new module and I don't want to create a new route for each hello.

Do you have any clue how I can solve this?

PD: This is an example, the real project has more routes on child, that's why I don't want create a new route for each component. I tried to use matcher but it's not working as UrlSegment is always length 0

Thank you

Estoy tratando de cargar de forma diferida un módulo -> menu.module # MenuModule

 rutas constantes: Rutas = [
         {
            camino: '',
            loadChildren: './home/home.module#HomeModule'
        }, {ruta: '**', loadChildren: './ menu.module # MenuModule'}];

MenuModule tiene otras rutas

rutas constantes: Rutas = [
    {ruta: 'hello', componente: HelloComponent, ruta de acceso: 'completo'},
{ruta: 'hello2', componente: Hello2Component, pathMatch: 'full'},
];

Necesito que hello y hello2 sean como http://server/hello o http://server/hello2 pero siempre entra en Home por la coincidencia con ''.

No quiero poner esas rutas (Hello y hello2) en padre, ya que quiero que ambos usen un nuevo módulo y no quiero crear una nueva ruta para cada 'hello'.

¿Tienes alguna idea de cómo puedo resolver esto?

PD: Este es un ejemplo, el proyecto real tiene más rutas en el router hijo, por eso no quiero crear una nueva ruta para cada componente. Probé de usar matcher pero no funciona ya que UrlSegment siempre tiene longitud 0

Gracias

se eliminaron 20 caracteres en el cuerpo
Origen Enlace

Dears,

I'm trying to lazy load a module -> menu.module#MenuModule

 const routes: Routes = [
         {
            path: '',
            loadChildren: './home/home.module#HomeModule'
        },   { path: '**', loadChildren:'./menu.module#MenuModule', pathMatch: >'full'} ];

MenuModule hae other routes

const routes: Routes = [
    { path: 'hello', component: HelloComponent , pathMatch: 'full' },
{ path: 'hello2', component: Hello2Component , pathMatch: 'full' },
];

I need that hello and hello2 be like http://server/hello or http://server/hello2 but it's always entering on home becuase the parent match with ''.

I don't want to put that routes (Hello and hello2) on parent as I want both use a new module and I don't want to create a new route for each hello.

Do you have any clue how I can solve this?

PD: This is an example, the real project has more routes on child, that's why I don't want create a new route for each component. I tried to use matcher but it's not working as UrlSegment is always length 0

Thank you

Dears,

I'm trying to lazy load a module -> menu.module#MenuModule

 const routes: Routes = [
         {
            path: '',
            loadChildren: './home/home.module#HomeModule'
        },   { path: '**', loadChildren:'./menu.module#MenuModule', pathMatch: >'full'} ];

MenuModule hae other routes

const routes: Routes = [
    { path: 'hello', component: HelloComponent , pathMatch: 'full' },
{ path: 'hello2', component: Hello2Component , pathMatch: 'full' },
];

I need that hello and hello2 be like http://server/hello or http://server/hello2 but it's always entering on home becuase the parent match with ''.

I don't want to put that routes (Hello and hello2) on parent as I want both use a new module and I don't want to create a new route for each hello.

Do you have any clue how I can solve this?

PD: This is an example, the real project has more routes on child, that's why I don't want create a new route for each component. I tried to use matcher but it's not working as UrlSegment is always length 0

Thank you

Dears,

I'm trying to lazy load a module -> menu.module#MenuModule

 const routes: Routes = [
         {
            path: '',
            loadChildren: './home/home.module#HomeModule'
        },   { path: '**', loadChildren:'./menu.module#MenuModule'} ];

MenuModule hae other routes

const routes: Routes = [
    { path: 'hello', component: HelloComponent , pathMatch: 'full' },
{ path: 'hello2', component: Hello2Component , pathMatch: 'full' },
];

I need that hello and hello2 be like http://server/hello or http://server/hello2 but it's always entering on home becuase the parent match with ''.

I don't want to put that routes (Hello and hello2) on parent as I want both use a new module and I don't want to create a new route for each hello.

Do you have any clue how I can solve this?

PD: This is an example, the real project has more routes on child, that's why I don't want create a new route for each component. I tried to use matcher but it's not working as UrlSegment is always length 0

Thank you

Origen Enlace
Loading