Merge pull request #16 from nmehta6/master

detecting if Json needs to be parsed or stringified as part of addToLocalStorage() and getFromLocalStorage()
dev
grevory 11 years ago
commit 335676452a

@ -52,6 +52,9 @@ angularLocalStorage.service('localStorageService', [
if (typeof value == "undefined") value = null;
try {
if (angular.isObject(value)) {
value = angular.toJson(value);
}
localStorage.setItem(prefix+key, value);
if (notify.setItem) {
$rootScope.$broadcast('LocalStorageModule.notification.setitem', {key: key, newvalue: value, storageType: 'localStorage'});
@ -73,6 +76,9 @@ angularLocalStorage.service('localStorageService', [
var item = localStorage.getItem(prefix+key);
if (!item) return null;
if (item.charAt(0) === "{") {
return angular.fromJson(item);
}
return item;
};