Here's the service
.factory('$localstorage', ['$window', function($window) {
return {
get: function(key, defaultValue) {
return $window.localStorage[key] || defaultValue;
},
getObject: function(key) {
return JSON.parse($window.localStorage[key] || '{}');
}
}
}]);
and I do console.log($localstorage.getObject('name'));
it gave me an error saying Unexpected token [
Here's how my key and value look like as localstorage
{["a","b","c"]}
what's wrong actually?