Skip to content

Instantly share code, notes, and snippets.

@melloc01
Created December 29, 2014 12:29
Show Gist options
  • Save melloc01/0f977e56c6e6da146b35 to your computer and use it in GitHub Desktop.
Save melloc01/0f977e56c6e6da146b35 to your computer and use it in GitHub Desktop.
(function (angular) {
angular.module('app').service('StorageService', [function () {
var service = {
setItem : setItem,
getItem : getItem,
removeItem : removeItem
};
return service;
function setItem (key, value) {
localStorage.setItem(key,JSON.stringify(value));
}
function getItem (key) {
return JSON.parse(localStorage.getItem(key));
}
function removeItem (key) {
localStorage.removeItem(key);
}
}]);
})(angular);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment