javascript - how to store login info with angularJS -


i develloping little app angularjs; users have go through login form , can click on few links display data fetched server.

the login form takes user's input , "stored" factory

app.factory('idformholder', function () {     var = this;      that.setid = function (data) {         = data;      };     that.getid = function () {         return that;     };      return that; }); 

which works fine need keep stored because server requires login form sent each time $http.get header.

each controller takes login form factory , uses data server.

this works fine until decides refresh page, @ point seems factory "emptied" login form, , web-app fails show anything.

is there way store login info doesn't erased ?

you can use code after youve installed sessionstorage:

app.factory('idformholder', ['$sessionstorage', function ($sessionstorage) {     var = this;      that.setid = function (data) {         $sessionstorage.id = data;         = data;      };     that.getid = function () {         return $sessionstorage.id;     };      return that; }]); 

download link: https://github.com/gsklee/ngstorage


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -