Click here to Skip to main content
15,887,288 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
Form data not return from the localStorage

What I have tried:

$scope.Submit = function () {
console.log("users" + self.users);
// self.users.push(self.users);
localStorage.setItem("Users", JSON.stringify(self.user));
}

if (localStorage.getItem('Users') != null) {
$scope.users = JSON.parse(localStorage.getItem("Users"));
console.log("users" + (localStorage.getItem("Users")));
}
Posted
Updated 23-Sep-21 1:09am

Quote:
JavaScript
console.log("users" + self.users);
localStorage.setItem("Users", JSON.stringify(self.user));
You log the value of the users variable, but store the value of the user variable. Which is it?
 
Share this answer
 
v2
A few things I'd try:

- Ensure that self.user is not null.

- Put a breakpoint where you are storing the data then go to developer tools and see if you find it in the local storage section.

At what point are you calling the getItem function? Can you show your entire controller code?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900