0

I have designed a login page application in Angular js. but I need a help in the browser when I click back button it again navigating to home page or login page for to stop back button work what should we do.

when I click back button in browser it should not navigate to home page or login page.

1

1 Answer 1

1

Please see working example: http://plnkr.co/edit/46O0znC5HFDE4cYXSm5h?p=preview

Stored data in cookies in login function as follows,

$cookies.userinfo = {
    'id': 1,
    'name': 'pqr'
};

And on logout remove that data -

delete $cookies.userinfo;

then check for 'angular.isDefined($cookies.userinfo)' (userinfo is cookie name which given at the time of storing data in it) if find then redirect it to your page which you want to see after login. i.e

app.run(function ($cookies) {
      $rootScope.$on("$routeChangeStart", function () {
        if (angular.isDefined($cookies.userinfo)) {
            $location.path("/pathname");
        }

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

Comments

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.