0

My app hierarchy is as follows:

  1. app(root)
    • Modules (module)
      • Master
      • Detail
        • Nav
        • Create/home (component)
        • Fields (module)
          • Detail (component)
          • Master (component)

modules-routing.module.ts

const routes: Routes = [
 { path: 'modules-detail/:module_name', loadChildren: './module-detail/module-detail.module#ModuleDetailModule' },
 { path: '', component: ModulesMasterComponent }
];

modules-detail-routing.module.ts

const routes: Routes = [
{
 path: '',
 component: ModulesNavComponent,
 children: [
    { path: '', component: CreateModuleComponent },
    { path: 'new', component: CreateModuleComponent },
    { path: 'fields', loadChildren: './fields/fields.module#FieldsModule' }
 ]
}
];

fields-routing.module.ts

const routes: Routes = [
{
  path: '',
  component: FieldsMasterComponent
},
{
  path: ':field_id',
  component: FieldDetailComponent
}
];

Problem
When i redirect to /modules/testModuleName/fields, I am trying to access my module_name param thats declared in the modules-routing.module (testModuleName). However, my route params come up empty when i am in the fields module. I am able to see the param in the create/home component, but not in the child modules. Any help would be appreciated!

npabs18
  • 167
  • 2
  • 10

1 Answers1

4

How are you accessing the Param If you are using router.params

Then switch it to router.parent.params and it will get the id. Let me know if that works for you.

  • 1
    After accessing the params from the ActivatedRoute, i was able to find it under route.parent.parent.params as a grandfathered route. Thanks! – npabs18 Sep 11 '18 at 14:17