I have a toolbar component aligned above a router outlet. The router outlet has various components like table and chart.
Am able to subscribe to route params in any of the components that are displayed using a router outlet.
I want to access route params from toolbar component which is not part of outlet. (capture current path to show name of route on toolbar)
Main component :
<app-toolbar> </app-toolbar>
<router-outlet> </router-outlet> // shows either a table or chart component
toolbar component:
export class ToolbarComponent {
constructor(private route: ActivatedRoute) {
this.route.subscriber(params =>
{ console.log(params) //param is empty }
}
}
Table component:
export class TableComponent{
constructor(private route: ActivatedRoute) {
this.route.subscriber(params =>
{ console.log(params) //param has data }
}
}