How to navigate relative from /questions/123/step1
to /questions/123/step2
within a component using Router
without string concatenation an
Note: the routes are case sensitive so make sure you match the casing across
This worked for me for Angular 8:
From the parent component / page, to navigate to the sub page using typescript:
this.router.navigate(['subPage'], { relativeTo: this.route });
My router in the parent's module looks like this:
const routes: Routes = [
{
path: '',
component: MyPage,
children: [
{ path: 'subPage', component: subPageComponent}
]
}
];
And on the parent's html page use the following to navigate using a link:
Sub Page Link