In my application, I have a child component and its parent component. The child component uses the following pipe to subscribe to the activated route:
this.route.paramMap.pipe(
map(paramMap => +paramMap.get('id')),
switchMap((id: number) => this.apiService.getTasks(id.toString())),
).subscribe(tasks => this.tasks = tasks);
{ path: '', component: DashboardComponent, children: [
{ path: '', redirectTo: '0', pathMatch: 'full' },
{ path: '0', component: NoListComponent },
{ path: ':id', component: ListComponent }
]},
My question is how can I access the route parameter :id within the parent component DashboardComponent
?
I need to work with the same id in the parent component as well. I've attempted passing it via @ViewChild
, but this does not update upon route changes.
EDIT: Due to using router outlet, event emitting is not possible.