Angular $ location.path () and window.location.reload do not work in Safari / Firefox

For some reason this works in IE and Chrome, but not in Safari and firefox.

$location.path(lastPath); $window.location.reload(true); 

Instead of reloading the last path $window.location.reload(true) current page reloads. Where, as in Chrome IE, a reboot occurs after angular $location.path(lastPath) .

+6
source share
3 answers

Thanks. The problem is solved below.

 $window.location.href = lastPath; 
+2
source

You can do it:

 $window.location.href='#/home'; $window.location.reload() 
+2
source

I start with cordova with angular 1.5.6. Simple action:

 $location.path("/someurl"); $window.location.reload(); 

works in Chrome and Android app, but not in ios app. What works on all platforms reboots after changing the location path.

This is achieved using the $ locationChangeSuccess event. This is the complete controller code so that everything is clear. The $ location.path is tagged, and $ window.location.reload () is placed in the $ locationChangeSuccess handler.

 angular.module("demo").controller("LoginCtrl", function($scope, $http, $location, $window) { $scope.dologin = function() { $scope.message = ""; $http.post(app.baseurl + "/app/login", { email: $scope.email, password: $scope.password }, { withCredentials: true }).success(function(response){ $location.path("/dashboard"); // <--- }).error(function(response) { $scope.message = "invalid user/pass: "; }); } $scope.$on('$locationChangeSuccess', function() { $window.location.reload(true); // <--- }); 

});

+1
source

All Articles