Store data on mobile devices (using cordova) that persists even if the user reinstalls the app
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
.gitignore
.jshint
README.md
bower.json
gulpfile.js
package.json

README.md

ng-persist

Install

$ bower install ng-persist ngstorage --save

For ios, KeychainPlugin is required:

$ cordova plugin add https://github.com/driftyco/cordova-plugin-ios-keychain.git

For Android, cordova-plugin-file is required:

$ cordova plugin add cordova-plugin-file

Usage

Require ng-persist and ngstorage

angular.module('myApp', [
    'ngStorage',
    'ng-persist'
]);

Inject $persist into your controller

.controller('MyCtrl', function($persist) {

    // write
    $persist
        .set(namespace, key, val)
        .then(function () {
            // saved
        });

    // read
    $persist
        .get(namespace, key, fallback)
        .then(function (val) {
            // val is either the value, if exists, or the fallback
        });

    // delete
    $persist
        .remove(namespace, key)
        .then(function () {
            // removed
        });

});

License

MIT