Reputation: 513
Is there way to on (click) goBack($event)
i need to go back two steps instead just this.location.back() is there list of location array and i need to cut one last element.
Upvotes: 1
Views: 1396
Reputation: 12227
Unless there is absolutely no way that the user can land on this route directly (such as following links, storing a bookmark, or clicking a link in an email, etc) it will be too fragile.
What if someone bookmarked the page but the "home" link actually fires location.back()
: they'll end up on whatever site they were on before.
You should use static linking to known routes instead.
Upvotes: 1
Reputation: 161
If it is back two levels, you should be able to do something like:
this.router.navigate(['../../'], { relativeTo: this.route });
Upvotes: 0