summaryrefslogtreecommitdiff
path: root/www/js/ionicUtils.js
blob: c593624cd56a6322d19761fdbae09dd010682b6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* jshint -W041 */
/* jshint browser: true*/
/* global cordova,StatusBar,angular,console */

//http://learn.ionicframework.com/formulas/localstorage/

angular.module('ionic.utils', [])

.factory('$localstorage', ['$window', function($window)
{
    return {

        init: function() {},

        set: function(key, value)
        {
            $window.localStorage[key] = value;
        },
        get: function(key, defaultValue)
        {
            return $window.localStorage[key] || defaultValue;
        },
        setObject: function(key, value)
        {
            $window.localStorage[key] = JSON.stringify(value);
        },
        getObject: function(key)
        {
            return JSON.parse($window.localStorage[key] || '{}');
        }
    };
}]);