Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace history and then redirect in AngularJS

While trying to access window.location or window.history directly, how can I do the following in AngularJS:

  1. Replace the history for current location
  2. Redirect to a new location

For example:

  • user goes to "/#/loc1"
  • I want the history to show they went to "/#/loc2"
  • Then redirect to "/#/loc3"
  • If they use the browser.back, it should return them to "#/loc2"
like image 937
wag2639 Avatar asked Oct 05 '13 03:10

wag2639


1 Answers

Is this what you want?

$location.path('/blahblah').replace();

See API Docs for $location

like image 160
ivarni Avatar answered Oct 09 '22 05:10

ivarni