I need to get all the lists when I storing the object records in local storage on every button clicks.
I tried like below, but on every click getting the same record which setting in present click, not getting previous clicks set records.
- $scope.AddToCart = function () { var items = [];
- var listItems = { Garment: list.ItemName, Quantity: itemQty, Price: list.DryClean, Service: service, Total: totalPrice};
- items.push(listItems); localStorage.setItem('listItems', JSON.stringify(items));
- var stored = JSON.parse(localStorage.getItem("listItems")); c
- onsole.log(stored);
I would like to get like below
On first click :0: {Garment: "Thobe", Quantity: "1", Price: 5, Service: "", Total: 5}
On second click :
0: {Garment: "Thobe", Quantity: "1", Price: 5, Service: "", Total: 5}
1: {Garment: "Shirt", Quantity: "1", Price: 20, Service: "", Total: 25}
on third click :
0: {Garment: "Thobe", Quantity: "1", Price: 5, Service: "", Total: 5}
1: {Garment: "Shirt", Quantity: "1", Price: 20, Service: "", Total: 5}
2: {Garment: "Pant", Quantity: "1", Price: 30, Service: "", Total: 55}