Only one data store localStorage JSON data using AngularJS -
i have problem in store localstorage json feeds stores 1 data. when add more data, shows one. please me!
stored values
var fav_game = [{ id : "1212", name : "cricket" }];
store localstorage data
window.localstorage['favgame'] = json.stringify(fav_game); var favgame = json.parse(window.localstorage['favgame'] || '{}');
get local storage items:
$scope.favgame = json.parse(localstorage.getitem('fav_game')) || []; console.log(localstorage['favgame']);
var fav_game = [{ id : "1212", name : "cricket" }]; window.localstorage['favgame'] = json.stringify(fav_game); function addvalue(key,val){ temp = []; tmp = localstorage.getitem(key); if(tmp != null){ temp.push(json.parse(tmp)); temp.push(val); window.localstorage['favgame'] = json.stringify(temp) } } addvalue('favgame','here valid data')
Comments
Post a Comment