Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip a page in browser history when navigating back?

I have an Angular 2 app with the Router. Let's say the user is on a page A in the app, he then navigates to a page B and then to a page C. At this moment when he clicks the Back button on the browser I want him to get back to the page A (by skipping B). How can I achieve it?

like image 225
mschuster Avatar asked Jan 26 '17 13:01

mschuster


2 Answers

When navigating from B to C one has to set { replaceUrl: true }:

this.router.navigate(["/c"], { replaceUrl: true });

This replaces the page B by C in the browser history.

like image 185
mschuster Avatar answered Oct 19 '22 07:10

mschuster


Quick and easy solution is

Use navigation in your typescript instead of html file .

And specify the parameter

{ skipLocationChange: true }

Proper solution is to write your own navigation strategy and specify in app.modules.ts

like image 1
Parth Ghiya Avatar answered Oct 19 '22 08:10

Parth Ghiya