Skip to main content
added 253 characters in body
Source Link
floribon
  • 19.2k
  • 5
  • 56
  • 68

Angular code is executed client side only, so any state will disappear once you reload the page.

If you want to keep information between two user session, you have many options:

  • Keep that info in the URL using $location or location
  • Store that info in localStorage and retrieve it next time
  • Persist the information server side and query your server to get it back

Follow-up:

Once you get your token you can do:

localStorage.setItem('myToken', $rootScope.jwtToken);

And when you load your application, check if a token has been stored:

$rootScope.jwtToken = localStorage.getItem('myToken');

Angular code is executed client side only, so any state will disappear once you reload the page.

If you want to keep information between two user session, you have many options:

  • Keep that info in the URL using $location or location
  • Store that info in localStorage and retrieve it next time
  • Persist the information server side and query your server to get it back

Angular code is executed client side only, so any state will disappear once you reload the page.

If you want to keep information between two user session, you have many options:

  • Keep that info in the URL using $location or location
  • Store that info in localStorage and retrieve it next time
  • Persist the information server side and query your server to get it back

Follow-up:

Once you get your token you can do:

localStorage.setItem('myToken', $rootScope.jwtToken);

And when you load your application, check if a token has been stored:

$rootScope.jwtToken = localStorage.getItem('myToken');
Source Link
floribon
  • 19.2k
  • 5
  • 56
  • 68

Angular code is executed client side only, so any state will disappear once you reload the page.

If you want to keep information between two user session, you have many options:

  • Keep that info in the URL using $location or location
  • Store that info in localStorage and retrieve it next time
  • Persist the information server side and query your server to get it back