public onSubmit(id, product_name){

var data = {
   id,
   product_name
};


this.items.push(data);
localStorage.setItem(this.storageKey, JSON.stringify(this.items));
var retrieverObject = localStorage.getItem('this.items.id');
var retrieveObject = JSON.parse(retrieverObject);
if (retrieveObject == id) {
    alert('test');
}
}


I want to check if the value has already been submitted. This is part of a 
shopping cart application in which the product quantity will be updated if 
the product has already been chosen.

When I use
var retrieverObject = localStorage.getItem('MyDataStorageKey');


it returns:
[{"id":0,"product_name":"Adult Male Bike"},{"id":0,"product_name":"Adult 
Male Bike"}] 



All of the following return null
   
var retrieverObject = localStorage.getItem('MyDataStorageKey.findIndex(id)'
);
var retrieverObject = localStorage.getItem('MyDataStorageKey.indexOf("id")'
);
var retrieverObject = localStorage.getItem('MyDataStorageKey.indexOf(id)');
var retrieverObject = localStorage.getItem('MyDataStorageKey[0].id');
var retrieverObject = localStorage.getItem('MyDataStorageKey[0]');
var retrieverObject = localStorage.getItem(
'MyDataStorageKey.findIndex("id")');
var retrieverObject = localStorage.getItem('MyDataStorageKey["id"]');
var retrieverObject = localStorage.getItem('MyDataStorageKey.id');

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/5cae073a-3651-463d-b4a3-526fecb2f3aao%40googlegroups.com.

Reply via email to