-1

I want to refresh a URL upon successful login without a page refresh. I am using the following code

$scope.Login = function (teacher, chkRememberMe) {
    alert(chkRememberMe);
    $http.post("/Teacher/Login", { teacher: teacher, chkRememberMe: chkRememberMe })
    .success(function (result) {
        if (result == "True") {
            toastr.success("You are Login successfully!!!");
            $timeout(function () { }, 5000);
            $timeout(function () { }, 5000);
            $location.path('Teacher/Index');
        }
        else {
            toastr.error("The email and password you entered don't match.")
            window.location = "/Teacher/Login";
        }
    })
    .error(function (error) {
        error.message
        alert(error);
        toastr.error("The email and password you entered don't match11")
    })
}

The URL is not updating successfully.

2
  • Fixed wording and spelling errors. Commented Aug 23, 2016 at 16:21
  • I believe that what you want is ngRoute which is documented here: docs.angularjs.org/api/ngRoute/service/$route Commented Aug 23, 2016 at 18:42

1 Answer 1

0

You can use history.replaceState(data,title,url) to accomplish this. There's a bit of documentation at MDN. The history.js library may be of interest as well.

If you're trying to handle single-page authentication with angular, it can be a hassle. You may want to take a look at AngularJS: Basic example to use authentication in Single Page Application for more on this.

An aside: you may also want to consider taking steps to ensure that password managers function as you'd expect. There are a few stackoverflow questions which address these concerns (e.g., How to make Chrome remember password for an AJAX form?).

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

1 Comment

i am not talking about browser history. i am talking about when any user login first time then we check user name and password if both are correct then move to next page with out url refresh with help of angular js. I am talking about just move from one page to other page without url refresh with help of angular js.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.