#angular-forage A Javascript library extend localforage with angular. You can set expire time when store data.
bower install angular-forage --save
Reference these files in your index.html
<script src="path/to/bower_components/localforage/dist/localforage.nopromises.min.js"></script>
<script src="path/to/bower_components/angular/angular.min.js"></script>
<script src="path/to/bower_components/angular-forage/dist/angular-forage.min.js"></script>Include the module as a dependency in your angular.module
angular.module('yourApp', ['ngForage']);Finally, using it:
angular.module('yourApp').config(function($forageProvider) {
//config
$forageProvider.config({prefix: '_demo_'});
}).controller('YourCtrl', function( $scope, $forage ) {
$forage.set('key', 'value');
$forage.get('key').then(function (data) {
//console.log(data);
}, function (err) {
//console.log(err.message);
});
});| Param | Type | Detail |
|---|---|---|
| key | string | |
| data | object | |
| expire_at | number | expire timestamp;optional parameter,if not set will use the infinite time |
| Param | Type | Detail |
|---|---|---|
| driver | array | for localforage |
| transformError | function | set a error transform function |