TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
dawood abbas
NA
56
4.7k
How to set a record on every click in localstorage and get?
Jul 16 2019 11:58 PM
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}
Reply
Answers (
1
)
How to pass data from one component to another component
What are the new features in Angular 7 ?