You can create a local storage factory in Ionic and use it.
Here is the factory:
Here is the factory:
var peerHealthApp = angular.module('PeerHealthApp');
peerHealthApp.factory('$localStorage', ['$window', function($window) {
return {
store: function(key, value) {
$window.localStorage[key] = value;
},
get: function(key, defaultValue) {
return $window.localStorage[key] || defaultValue;
},
storeObject: function(key, value) {
$window.localStorage[key] = JSON.stringify(value);
},
getObject: function(key,defaultValue) {
return JSON.parse($window.localStorage[key] || defaultValue);
}
}
}]);
To Use it:
$localStorage.storeObject("userDetails.token", someValue);
No comments:
Post a Comment