Skip to content

Commit 8fdc829

Browse files
committed
2 parents 728d0b4 + 67f2b5e commit 8fdc829

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/localStorage.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
angular.module('localStorage', ['ngCookies']).factory('$store', function ($parse, $cookieStore) {
1+
angular.module('localStorage', ['ngCookies']).factory('$store', function ($parse, $cookieStore, $window, $log) {
22
/**
33
* Global Vars
44
*/
5-
var storage = (typeof window.localStorage === 'undefined') ? undefined : window.localStorage;
6-
var supported = !(typeof storage === 'undefined' || typeof window.JSON === 'undefined');
5+
var storage = (typeof $window.localStorage === 'undefined') ? undefined : $window.localStorage;
6+
var supported = !(typeof storage === 'undefined' || typeof $window.JSON === 'undefined');
77

88
var privateMethods = {
99
/**
@@ -14,7 +14,7 @@ angular.module('localStorage', ['ngCookies']).factory('$store', function ($parse
1414
parseValue: function (res) {
1515
var val;
1616
try {
17-
val = JSON.parse(res);
17+
val = $window.JSON.parse(res);
1818
if (typeof val === 'undefined') {
1919
val = res;
2020
}
@@ -24,8 +24,8 @@ angular.module('localStorage', ['ngCookies']).factory('$store', function ($parse
2424
if (val === 'false') {
2525
val = false;
2626
}
27-
if (parseFloat(val) === val && !angular.isObject(val)) {
28-
val = parseFloat(val);
27+
if ($window.parseFloat(val) === val && !angular.isObject(val)) {
28+
val = $window.parseFloat(val);
2929
}
3030
} catch (e) {
3131
val = res;
@@ -47,10 +47,10 @@ angular.module('localStorage', ['ngCookies']).factory('$store', function ($parse
4747
$cookieStore.put(key, value);
4848
return value;
4949
} catch(e) {
50-
console.log('Local Storage not supported, make sure you have angular-cookies enabled.');
50+
$log.log('Local Storage not supported, make sure you have angular-cookies enabled.');
5151
}
5252
}
53-
var saver = JSON.stringify(value);
53+
var saver = $window.JSON.stringify(value);
5454
storage.setItem(key, saver);
5555
return privateMethods.parseValue(saver);
5656
},

0 commit comments

Comments
 (0)