javascript - How to store User Data in AngularJs -
Can anyone tell me how the user data has been logged in the Global Realm of AngularJS, < p> My login service looks like this
App.service ('Auth', function ($ http) {return} is {logon: function (callback) {$ http.get ( 'api / auth / success (callback (res);});}, login: function (user, callback) {$ http.post (' api / auth / login ', user) .success (function Res) {callback (res);}}}, logout: function (callback) {$ http.get ('api / auth / logout'). Success (function (Race) {callback (res);}}}}};}); I'm using the same in my controller like this
$ scope.isLogin = false; $ scope.UserData = {}; $ scope.login = function (user) {Auth.login (user, function (res) {if (res.status) {$ scope.isLogin = true ; $ scope.loginBoxShown = false; $ scope.UserData = res.data; $ location.path ('/ dashboard');}});}; On this first run Works fine, but once I reload the page, the variable $ scope.isLogin and $ scope.UserData are resetting > Is my $ scope.logout (); Before deleting the function permanently there is a way to store them in global scope.
I usually use ngStorage for user data persistence.
found in the Angular JS module, which works on Web Storage in Kangra Marg. There are two services: $ local storage and $ session storage.
Hope it helps.
Comments
Post a Comment