Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2, relative navigation (two levels back ../../)

I have a back button in my application, which navigates relatively some levels back. In case of one level

this.router.navigate(['..'], { relativeTo: this.route });

it works perfectly (resulted route url:http://localhost:3000/three/two/one). In case of two level back rel. navigation

this.router.navigate(['..', '..'], { relativeTo: this.route });

router navigates two levels back, BUT the resulted route url looks now like http://localhost:3000/three/two/(tailing slash, which is not correct).

Am I doing something wrong or could it be a bug?

like image 342
user3287019 Avatar asked Dec 05 '22 14:12

user3287019


1 Answers

In case of two levels down use this:

this.router.navigate(['../../'], { relativeTo: this.route });
like image 74
Robin Dijkhof Avatar answered Dec 31 '22 12:12

Robin Dijkhof