Closed siddmegadeth closed 8 years ago
try something like this
var item = {
"name: "someone",
"age" : 23,
"gender" : "male"
}
//Init
$scope.storage = $localStorage;
// if allSelectedTweets doesn't exist or length is 0, initial a empty object and fill with item
if(!$scope.storage.allSelectedTweets || $scope.storage.allSelectedTweets.length === 0) {
$scope.storage.allSelectedTweets = [];
$scope.storage.allSelectedTweets.push(item);
}
everytime you refresh he set a empty array to "allSelectedTweets". but with a little check he will not update it till its empty or undefined/null
Midako with the save!
👍
Canot get this below code to work. I am having large set of JSON which has to be added to localstrorage var item = { "name: "someone", "age" : 23, "gender" : "male"
} //Init $scope.storage = $localStorage; $scope.storage.allSelectedTweets = [];
$scope.storage.allSelectedTweets.push(item);
On Page refresh all the values are gone.