How to navigate relative from /questions/123/step1
to /questions/123/step2
within a component using Router
without string concatenation an
First, inject router & ActivatedRoute on constructor
constructor(private route:ActivatedRoute,private router:Router) { }
then use to Click Event:
onEditClick(){
this.router.navigate(['edit'],{relativeTo:this.route});
You navigate to the expected page.In my scenario, I wanted to go recipe /1 to edit the recipe. http://localhost:4200/recipes/1/edit