tothefux
tothefux

Reputation: 223

Angular 4 Custom Router Navigation

Lets say I navigate from page A --> B --> C

How can I remove page B from the navigation history so that when when I am on page C and press browser back it goes to page A?

Upvotes: 0

Views: 778

Answers (2)

DeborahK
DeborahK

Reputation: 60518

You could try skipLocationChange.

// Navigate silently to /view (Component B)
this.router.navigate(['/view'], { skipLocationChange: true });

That navigates without pushing its state into history.

The docs for this is here: https://angular.io/docs/ts/latest/api/router/index/NavigationExtras-interface.html#!#skipLocationChange-anchor

Upvotes: 1

Julia Passynkova
Julia Passynkova

Reputation: 17869

I don't think Angular expose a public API to do it right now but if your app uses only a browser platform you can probably do it

  window.history.go(-2);

Upvotes: 3

Related Questions