0
I’m trying to add data to Localstorage through a form. However, it always replaces the value and does not appear the key I had determined (it is as 1).
In this code snippet is when it takes the user object (it is an input) and sends to Localstorage only the "user.name". It sends the value.
register(user: User) {
this.user = new User;
window.localStorage.setItem('user', user.name);
}
Result in Localstorage :
You can see that the key (key) is not the one I set (user). And consequently, when I make other insertions, with other keys, it replaces the value.