Skip to content

Knorcedger/angularjs-browser-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angularjs-browser-storage

This is an Angular.js module that provides easy access (read/write/remove/clear) to the browser's local and session storage.

Demo

http://jsfiddle.net/Knorcedger/nR4My/

The jsfiddle demo also exists inside the repository in the demo folder.

Usage

Your app must list browserStorage as a dependency. Then, you should also list the browserStorage service as dependancy in your Controllers.

Save
// Saves to localStorage
browserStorage.local.save('mykey', 'myvalue');
// Saves to sessionStorage
browserStorage.session.save('mykey', 'myvalue');
Save with expiration (in milliseconds)
// 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);
Load
// Loads from localStorage
browserStorage.local.load('mykey');
// Loads from localStorage
browserStorage.session.load('mykey');
Remove
// Removes this key from localStorage
browserStorage.local.remove('mykey');
// Removes this key from localStorage
browserStorage.session.remove('mykey');
Clear
// 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.

About

An Angular.js module that makes using local and session storage easy

Resources

License

Stars

Watchers

Forks

Packages

No packages published