Hello im new in typeScript and Angular. I need to get a value in storage, the storage.get return a promise, so i try:
getNomeUsuario():string{
var that = this;
this.storage.get('nomeUsuario').then(function(nome){
that.nomeUsuario = nome;
}.bind(this));
return this.nomeUsuario;
}
The problem is that always return a undefined. I also get the same with an arrow function.
getNomeUsuario():string{
this.storage.get('nomeUsuario').then((nome)=>{
this.nomeUsuario = nome;
});
return this.nomeUsuario;
}
How can I return the nome value ?
Sorry about my English hehe