diff options
| author | Arjun Roychowdhury <pliablepixels@gmail.com> | 2015-11-11 11:26:34 -0500 |
|---|---|---|
| committer | Arjun Roychowdhury <pliablepixels@gmail.com> | 2015-11-11 11:26:34 -0500 |
| commit | 1ab390f225b727303df305fefa72bb3ac4b069b8 (patch) | |
| tree | 5cdde2836527098ec0e4b8539b0769dff1c7128c /www/js/ionicUtils.js | |
| parent | f087b5f125f5545252e2f426582f910d0b88e241 (diff) | |
#81 - initial commits to start using localstorage
Former-commit-id: 18a55518ba7f11881a677092b5f1c1a35be1b443
Diffstat (limited to 'www/js/ionicUtils.js')
| -rw-r--r-- | www/js/ionicUtils.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/www/js/ionicUtils.js b/www/js/ionicUtils.js new file mode 100644 index 00000000..ac79e87e --- /dev/null +++ b/www/js/ionicUtils.js @@ -0,0 +1,22 @@ +/* jshint -W041 */ +/* jshint browser: true*/ +/* global cordova,StatusBar,angular,console */ + +angular.module('ionic.utils', []) + +.factory('$localstorage', ['$window', function($window) { + return { + 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] || '{}'); + } + }; +}]); |
