Created
November 15, 2015 12:03
-
-
Save hitautodestruct/c4ab72d6dd838e837174 to your computer and use it in GitHub Desktop.
AngularJS service for getting and setting data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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