0

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);

2 Answers 2

3

$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

Sign up to request clarification or add additional context in comments.

Comments

1

Edit the href value from window object, for example (I assume your page is home.html):

$window.location.href = 'home.html';

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.