angularLocalStorage icon indicating copy to clipboard operation
angularLocalStorage copied to clipboard

Prevent ngRepeat duplicate error

Open thombrg opened this issue 11 years ago • 1 comments

if localstorage bound object is used in ngRepeat, then the object will be persisted to localstorage with $$hashkey, potentially causing the aforementioned error. this can either be addressed by using track by in the ngRepeat construct or adjusting the code in angularlocalstorage to strip the hashkey before set.

recommended change: var saver = $window.JSON.stringify(value, function(key, val) { if(key == '$$hashKey') { return undefined; } return val; });

thombrg avatar Feb 04 '14 13:02 thombrg

@thombrg - I have created a new Plunker that uses ngRepeat, let me know if the following doesn't match what you are seeing.

http://plnkr.co/edit/PNLjDEaRKtpLgGZMJypk?p=preview

hppycoder avatar Jan 30 '15 15:01 hppycoder