0
Good afternoon, I’m trying to save the data (with Localstorage) from an input into a variable, but I’m not getting it right. The page itself is an option to Save user data.
Follow the . html
<ion-item>
<ion-label position="Fixed">Nome</ion-label>
<ion-input [(ngModel)]="nome">{{nome1}}</ion-input>
</ion-item>
<ion-button expand="block" (click)="saveInformations()">Salvar</ion-button>
Follow the . ts
nome : string;
nome1: string;
saveInformations(){
localStorage.setItem('nome', this.nome);
this.nome1 = this.nome
}
ngOnInit() {
localStorage.getItem(this.nome)
}
When I leave the page and come back the input appears blank, what I’m doing wrong?
No, but what about the getItem('name') ???
– LeAndrade
Whoa, I forgot to put the whole code.
– rzp