-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-local-store.js
More file actions
42 lines (35 loc) · 887 Bytes
/
angular-local-store.js
File metadata and controls
42 lines (35 loc) · 887 Bytes
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
33
34
35
36
37
38
39
40
41
42
angular.module('ngLocalStore', []).service('$localStore', function() {
var LocalStore;
LocalStore = (function() {
function LocalStore() {}
LocalStore.prototype.get = function(key) {
var result;
try {
result = JSON.parse(localStorage.getItem(key));
}
catch (err) {
result = null;
}
return result;
};
LocalStore.prototype.put = function(key, value) {
if (value)
try {
return localStorage.setItem(key, JSON.stringify(value));
}
catch (error) {
return false;
}
else
return false;
};
LocalStore.prototype.remove = function(key) {
return localStorage.removeItem(key);
};
LocalStore.prototype.clear = function(key) {
return localStorage.clear();
};
return LocalStore;
})();
return new LocalStore();
});