Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

localstorage getitem angular

    // Parse any JSON previously stored in allEntries
  var existingEntries = JSON.parse(localStorage.getItem("store_owner_ad_contacts"));
  if(existingEntries == null) existingEntries = [];

  var adId = {
    "id":$scope.adId
  };
  // Save allEntries back to local storage
  existingEntries.push(adId);
  localStorage.setItem("store_owner_ad_contacts", JSON.stringify(existingEntries));

  var values = JSON.parse(localStorage.getItem("store_owner_ad_contacts"));
  angular.forEach(values, function(value, key) {

  // ^ This is coming as an object how can I get the key value?

   if(value == adId){
   //form has been submitted before
   }else{
   // showformVar = true 

    console.log(key + ': ' + value);
  });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #localstorage #getitem #angular
ADD COMMENT
Topic
Name
7+8 =