Replace history and then redirect in AngularJS

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

  • Replace history for current location
  • Redirect to a new location

For example:

  • user goes to "/ # / loc1"
  • I want history to show that they went to "/ # / loc2"
  • Then redirect to "/ # / loc3"
  • If they use browser.back, it should return them to "# / loc2"
+8
javascript angularjs url-redirection browser-history
source share
1 answer

Is this what you want?

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

See API Docs for $ location

+11
source share

All Articles