Home > Software design >  Angular pass route to lazy loaded module
Angular pass route to lazy loaded module

Time:01-20

i have a app-routing.module where at specified path i lazyload another module.

{
        path: 'ROUTE1',
        loadChildren: () => import('../modules/modulename/modulename.module').then((val) => val.modulename),
    },

this is the routing of my child module:

 {
        path: '',
        component: modulenameComponent,
    },
    {
        path: 'register/:id',
        loadChildren: () => import('../../modules/secondomodule/secondomodule.module').then((val) => val.secondomodule),
    },

What i want now if i go to the path: register/:id is go to the secondmodule.routing at

  {
        path: 'register/:id',
        component: Nomecomponent,
       
    },

instead of

  {
        path: '',
        component: OtherComponent,
       
    },

Is possible in lazyloading pass to the loaded module a specified path?

CodePudding user response:

In order to do what you want, your path would be

/register/123/register/123

since your route is a concatenation of all paths in hierarchy (root path child path recursive)

Rethink your navigation.

  • Related