angular get item from localstorage

Solutions on MaxInterview for angular get item from localstorage by the best coders in the world

showing results for - "angular get item from localstorage"
Claudia
13 May 2016
1var values = JSON.parse(localStorage.getItem("store_owner_ad_contacts"));
Janelle
19 Apr 2018
1JSON.parse(localStorage.getItem('key') || '{}');
Aliya
15 Jun 2019
1    // Parse any JSON previously stored in allEntries
2  var existingEntries = JSON.parse(localStorage.getItem("store_owner_ad_contacts"));
3  if(existingEntries == null) existingEntries = [];
4
5  var adId = {
6    "id":$scope.adId
7  };
8  // Save allEntries back to local storage
9  existingEntries.push(adId);
10  localStorage.setItem("store_owner_ad_contacts", JSON.stringify(existingEntries));
11
12  var values = JSON.parse(localStorage.getItem("store_owner_ad_contacts"));
13  angular.forEach(values, function(value, key) {
14
15  // ^ This is coming as an object how can I get the key value?
16
17   if(value == adId){
18   //form has been submitted before
19   }else{
20   // showformVar = true 
21
22    console.log(key + ': ' + value);
23  });
24