I am working on the Angular-6 project. I have many child routes for my application. One of them is as follow:
const routes: Routes = [
{
path: 'innovation-track/:innovation-track-id', component: InnovationTrackComponent,
children: [
{
path: 'sprint', component: ScrumBoardComponent
}
]
}
];
I want to get innovation-track-id value from URL in my ScrumBoardComponent.
I know I can get this by doing following:
constructor(private _route: ActivatedRoute) { }
//somewhere in method
this._route.snapshot.parent.paramMap
But, I want to fetch innovation-track-id value in any component, doesn't matter if it is child or parent. What I mean is I don't want to do the following:
this._route.snapshot.parent.paramMap
Instead, I want to do something as following:
this._route.params.<any parameter name>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…