-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.

Prune
  • 76,765
  • 14
  • 60
  • 81
Farhat Ullah
  • 79
  • 2
  • 9

1 Answers1

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?).

Community
  • 1
  • 1
dat
  • 1,580
  • 1
  • 21
  • 30
  • 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. – Farhat Ullah Aug 23 '16 at 18:07