Search code examples
angularnavigationrouterbrowser-history

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?


Solution

  • 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