0
I would like to know how to pass data from one item to a form in another view, using Ionic 3’s Native Localstorage.
I created a preview as shown below:
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
/*
Generated class for the MovimentosProvider provider.
See https://angular.io/guide/dependency-injection for more info on providers
and Angular DI.
*/
@Injectable()
export class MovimentosProvider {
lista:any[];
chave:string = "movimentos";
constructor(private storage: Storage) {
this.storage.ready().then(()=>{
this.storage.get(this.chave).then((registos) =>{
if(registos){
this.lista = registos;
}else{
this.lista = [];
}
});
});
}
listar(){
return this.lista;
}
adicionar(registro:any){
this.storage.ready().then(()=>{
this.lista.push(registro);
this.storage.set(this.chave, this.lista);
});
}
}
And I have a button editarMovimento
but I want to pass what you captured from the listing to the form and edit it.
editarMovimento(movimento:IMovimento){
this.movimento = movimento;
}
How can I do?
Thanks @Renan Rafael, it worked.
– Ramos