Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/angularLocalStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ angular.module('angularLocalStorage', ['ngCookies']).factory('storage', ['$parse
* Global Vars
*/
var storage = (typeof $window.localStorage === 'undefined') ? undefined : $window.localStorage;
var supported = !(typeof storage === 'undefined' || typeof $window.JSON === 'undefined');
var supported = !(typeof storage === 'undefined');

var privateMethods = {
/**
Expand All @@ -14,7 +14,7 @@ angular.module('angularLocalStorage', ['ngCookies']).factory('storage', ['$parse
parseValue: function (res) {
var val;
try {
val = $window.JSON.parse(res);
val = angular.fromJson(res);
if (typeof val === 'undefined') {
val = res;
}
Expand Down Expand Up @@ -50,7 +50,7 @@ angular.module('angularLocalStorage', ['ngCookies']).factory('storage', ['$parse
$log.log('Local Storage not supported, make sure you have angular-cookies enabled.');
}
}
var saver = $window.JSON.stringify(value);
var saver = angular.toJson(value);
storage.setItem(key, saver);
return privateMethods.parseValue(saver);
},
Expand Down