An AngularJS module that makes Web Storage working in the Angular Way. Contains two services:
sessionStorage - We got this often-overlooked buddy covered.
Cleanly-Authored Code - Written in the Angular Way, well-structured with testability in mind.
bower install ngstorage
$sessionStorage) by reference to a hook under
$scope$storage = $localStorage;
And use it like you-already-know:
Optionally, specify default values using the
$default()method:$scope$storage = $localStorage;
With this setup, changes will be automatically sync'd between
$localStorage, and localStorage - even across different browser tabs!
If you're not fond of the presence of
$scope.$storage, you can always use watchers:
$scopecounter = $localStoragecounter || 42;$scope;$scope;
This, however, is not the way ngStorage is designed to be used with. As can be easily seen by comparing the demos, this approach is way more verbose, and may have potential performance implications as the values being watched quickly grow.
// Both will dodelete $scope$storagecounter;delete $localStoragecounter;
This will delete the corresponding entry inside the Web Storage.
If you wish to clear the Storage in one go, use the
Optionally, pass in an object you'd like the Storage to reset to:$localStorage;
You can store anything except those not supported by JSON:
NaN- Will be replaced with
undefined, Function - Will be removed.
$ npm install to install dependencies. Then run
$ grunt for minification.
Any contribution will be appreciated.