Angular 7 Router - Navigate without adding to the history
Thanks to NavigationExtras you can now use replaceUrl: boolean
inside navigate()
This will replace the current url, and the new URL will update in the address bar:
this.router.navigate([`/somewhere`], { replaceUrl: true });
That way when you press back it will not remember the previous page in the history.
As @IngoBürk Mentioned in the comment you can achieve the same result without using skiplocationChange
this.router.replaceUrl('path')
skipLocationChange
Navigates without pushing a new state into history.
this.router.navigateByUrl([`${pathWithoutFragment}#${newFragment}`], { skipLocationChange: true });
Ref:https://angular.io/api/router/NavigationExtras#skipLocationChange