angular-data-storage
v1.1.1
Published
An Angular module to storage data
Downloads
11
Readme
angular-data-storage
An Angular module to storage data.
Table of contents:
##Table of contents:
Get Started
(1) You can install angular-data-storage using 3 different ways: Git: clone & build this repository Bower:
$ bower install angular-data-storage --save
npm:
$ npm install angular-data-storage
(2) Include angular-data-storage.js
(or angular-data-storage.min.js
) from the dist directory in your index.html
, after including Angular itself.
(3) Add 'AngularDataStorage'
to your main module's list of dependencies.
When you're done, your setup should look similar to the following:
<!doctype html>
<html ng-app="myApp">
<head>
</head>
<body>
...
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="bower_components/js/angular-data-storage.min.js"></script>
...
<script>
var myApp = angular.module('myApp', ['AngularDataStorage']);
</script>
...
</body>
</html>
##API Documentation ###save Directly save a value to storage.
myApp.controller('MainCtrl', function($scope, dataStorageService) {
//...
function submit(key, val) {
return dataStorageService.save(key, val);
}
//...
});
###fetch
Directly fetch a value from storage.
Returns: value from storage
myApp.controller('MainCtrl', function($scope, dataStorageService) {
//...
function getItem(key) {
return dataStorageService.fetch(key);
}
//...
});
###delete Remove an item(s) from storage by key.
myApp.controller('MainCtrl', function($scope, dataStorageService) {
//...
function deleteItem(key) {
return dataStorageService.delete(key);
}
//...
function deleteItems(key1, key2, key3) {
return dataStorageService.delete(key1, key2, key3);
}
});
###clearAll Remove all data from storage.
myApp.controller('MainCtrl', function($scope, dataStorageService) {
//...
function clearAll() {
return dataStorageService.clearAll();
}
});
###allKeys
Return array of keys for storage, ignore keys that not owned.
Returns: array with all keys from storage
myApp.controller('MainCtrl', function($scope, dataStorageService) {
//...
var lsKeys = dataStorageService.keys();
//...
});
###length
Return the number of keys from storage.
Returns: storage length
myApp.controller('MainCtrl', function($scope, dataStorageService) {
//...
function size() {
return dataStorageService.length();
}
//...
});