Reputation: 630
I am trying to redirest to home page after sweet alert from another page but it is not working , $location.path
is not working but console.log("Redirect is working")
in the code
setTimeout(function () {
swal({
title: "HI",
text: "Welcome.",
type: "warning",
confirmButtonText: "OK"
},
function () {
$location.path("home");
console.log("Redirect is working");
});
}, 100);
Upvotes: 0
Views: 106
Reputation: 2582
Edit the href value from window object, for example (I assume your page is home.html):
$window.location.href = 'home.html';
Upvotes: 1
Reputation: 3952
$location
does not cause a full page reload when the browser URL is changed. To reload the page after changing the URL, use "plain javascript" for that:
// like an HTTP redirect
window.location.replace("http://stackoverflow.com");
// like clicking on a link
window.location.href = "http://stackoverflow.com";
see the angularjs documentation for location: https://docs.angularjs.org/guide/$location
Upvotes: 3