Skip to content

Instantly share code, notes, and snippets.

@hitautodestruct
Created November 15, 2015 12:03
Show Gist options
  • Save hitautodestruct/c4ab72d6dd838e837174 to your computer and use it in GitHub Desktop.
Save hitautodestruct/c4ab72d6dd838e837174 to your computer and use it in GitHub Desktop.
AngularJS service for getting and setting data
app.factory('storage', function() {
var store = {}
function set(key, data) {
store = data;
localStorage.setItem( key, JSON.stringify( data ) );
}
function get( key ) {
store = localStorage.getItem( key );
store = JSON.parse( store );
return store;
}
return {
set: set,
get: get
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment