AngularJS $location not changing the path
Instead of $location.path(...)
to change or refresh the page, I used the service $window
. In Angular this service is used as interface to the window
object, and the window
object contains a property location
which enables you to handle operations related to the location or URL stuff.
For example, with window.location
you can assign a new page, like this:
$window.location.assign('/');
Or refresh it, like this:
$window.location.reload();
It worked for me. It's a little bit different from you expect but works for the given goal.
I had a similar problem some days ago. In my case the problem was that I changed things with a 3rd party library (jQuery to be precise) and in this case even though calling functions and setting variable works Angular doesn't always recognize that there are changes thus it never digests.
$apply() is used to execute an expression in angular from outside of the angular framework. (For example from browser DOM events, setTimeout, XHR or third party libraries).
Try to use $scope.$apply()
right after you have changed the location and called replace()
to let Angular know that things have changed.