ActivatedRoute .parent is an empty object in Angular 4

Viewed 1198

I am getting an empty object back on my route.parent.params on child route.

// parent.route.ts
const App_Routes = [
{ path: ':id', component: BoardComponent, 
      children: [
        { path: 'card', loadChildren: './board/cardwall/card/edit-card/edit-card.module#EditCardModule' }
      ] 
  },
  { path: '', redirectTo: ':id', pathMatch: 'full' }
];

//Child component
constructor(
   private route: ActivatedRoute
) { 
   this.route.parent.params.forEach((params: Params) => {
       console.log(params);
   });
}

This is how you get parent params as I understand it. What am I missing?

The below answer is not the correct answer.

1 Answers
Related