This is an Angular.js module that provides easy access (read/write/remove/clear) to the browser's local and session storage.
http://jsfiddle.net/Knorcedger/nR4My/
The jsfiddle demo also exists inside the repository in the demo folder.
Your app must list browserStorage as a dependency. Then, you should also list the browserStorage service as dependancy in your Controllers.
// Saves to localStorage
browserStorage.local.save('mykey', 'myvalue');
// Saves to sessionStorage
browserStorage.session.save('mykey', 'myvalue');
// saves the key for 1 second.
// When you will try to load it, after the 1 second, it will return null and delete the entry
browserStorage.local.save('mykey', 'myvalue', 1000);
browserStorage.session.save('mykey', 'myvalue', 1000);
// Loads from localStorage
browserStorage.local.load('mykey');
// Loads from localStorage
browserStorage.session.load('mykey');
// Removes this key from localStorage
browserStorage.local.remove('mykey');
// Removes this key from localStorage
browserStorage.session.remove('mykey');
// Removes everything from localStorage
browserStorage.local.clear();
// Removes everything from localStorage
browserStorage.session.clear();
A new utility service was added. The store service can be used to save variables either in a temp object (will be lost on refresh) or on browser localStorage.