0

There are only two points in the application where the login should appear:

  1. When I am not logged in and I attempt to visit a page that requires login, e.g. my profile page.
  2. When I attempt to make a request that requires a login, e.g. my session has expired whilst I’m attempting to post something.
1
  • 1
    You can search and use $sessonStorage or $coockiesStorage or $localStorage in angularjs Commented Sep 19, 2017 at 9:22

2 Answers 2

1
use HtML5 $sessonStorage or $localStorage.

Example
--------
sessionStorage.setItem('id', userId);
sessionStorage.getItem('id');
Sign up to request clarification or add additional context in comments.

1 Comment

is html 5 is compatible with all browsers?
1

With angularJS :

  • To save value : $window.sessionStorage.setItem('key', 'value')
  • To retreive value : $scope.name = $window.sessionStorage.getItem('key')

Here is a small example : http://jsfiddle.net/gioeleslfierro/s0pm6gcq/

I suggest you to use the angular way with $window. But if you want to do it by yourself its pretty similar (source) :

// Save data to sessionStorage
sessionStorage.setItem('key', 'value');

// Get saved data from sessionStorage
var data = sessionStorage.getItem('key');

// Remove saved data from sessionStorage
sessionStorage.removeItem('key');

// Remove all saved data from sessionStorage
sessionStorage.clear();

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.