Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS: How to remove current view url from window.history?

I have #/load-data view with spinner. When data load is complete controller redirects to differen view $location.path('/show-info/'). How to remove #/load-data from history to avoid window.history.back() to #/load-data view?

like image 324
Alexey Ryazhskikh Avatar asked Feb 26 '15 13:02

Alexey Ryazhskikh


1 Answers

You could use the $location.replace() method to replace the last history entry.

Here is the link to the documentation.

So when you are showing the spinner, you could switch to the actual view show-info with the following lines:

$location.path('/show-info/');
$location.replace();

Or shorter:

$location.path('/show-info/').replace();
like image 126
boindiil Avatar answered Dec 16 '22 21:12

boindiil