Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace the current route with other route

In Angular 2.0 to navigate to other route we can use route.navigate( [ 'routeName' ] ). But this action will store the current route in browser history.
What is the method to replace the current route in browser history and navigate to new route.

like image 900
user3603575 Avatar asked Sep 08 '25 11:09

user3603575


1 Answers

See this: https://angular.io/docs/ts/latest/api/router/index/NavigationExtras-interface.html

You have to use the option replaceUrl instead of skipLocationChange. It will send you to the new url but the current one will NOT be preserved, so pressing back will not send you back to this page.

this.router.navigate(['login'],{replaceUrl:true});
like image 99
fantasma_del_espacio Avatar answered Sep 11 '25 03:09

fantasma_del_espacio