Extracting information from storage in Ionic 2.
this.storage.get('name').then((nama) => {
this.name = nama
});
Now, I am trying to assign the extracted data "this.name" to an object. However, upon running the app, no data is being returned.
this.userData = {
id: '0404040404',
nama: this.name,
no_hp: '082211590346',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9abb0bfa8a0a3b8bab2a0b899beb4b8b0b5f7bab6b4">[email protected]</a>'
}
Below is my complete code snippet.
name:any
userData: {id: string, nama: string, no_hp: string, email: string}
constructor(public navCtrl: NavController,public storage: Storage) {
this.storage.get('name').then((nama) => {
this.name = nama
});
this.userData = {
id: '0404040404',
nama: this.name,
no_hp: '082211590346',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6f1d06091e16150e0c04160e2f08020e0603410c0002">[email protected]</a>'
}
}