Skip to content

Commit b2f3e2e

Browse files
committed
Fixes Issue agrublev#29 'Duplicates in a repeater are not allowed'
Use angular.fromJson() and angular.toJson() to prevent the "Duplicates in a repeater are not allowed" error that results from storage of $$ vars.
1 parent cfce3b6 commit b2f3e2e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/angularLocalStorage.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ angular.module('angularLocalStorage', ['ngCookies']).factory('storage', ['$parse
33
* Global Vars
44
*/
55
var storage = (typeof $window.localStorage === 'undefined') ? undefined : $window.localStorage;
6-
var supported = !(typeof storage === 'undefined' || typeof $window.JSON === 'undefined');
6+
var supported = !(typeof storage === 'undefined');
77

88
var privateMethods = {
99
/**
@@ -14,7 +14,7 @@ angular.module('angularLocalStorage', ['ngCookies']).factory('storage', ['$parse
1414
parseValue: function (res) {
1515
var val;
1616
try {
17-
val = $window.JSON.parse(res);
17+
val = angular.fromJson(res);
1818
if (typeof val === 'undefined') {
1919
val = res;
2020
}
@@ -50,7 +50,7 @@ angular.module('angularLocalStorage', ['ngCookies']).factory('storage', ['$parse
5050
$log.log('Local Storage not supported, make sure you have angular-cookies enabled.');
5151
}
5252
}
53-
var saver = $window.JSON.stringify(value);
53+
var saver = angular.toJson(value);
5454
storage.setItem(key, saver);
5555
return privateMethods.parseValue(saver);
5656
},

0 commit comments

Comments
 (0)