Created
November 7, 2016 16:52
-
-
Save vanckruz/92d6ea6ac114e6d28e88eb22caddc82a to your computer and use it in GitHub Desktop.
I can not understand why it does not assign the value to the variable this.userProfile ...can you help me?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { NavController, NavParams, LoadingController } from 'ionic-angular'; | |
import { Storage } from '@ionic/storage'; | |
import * as localforage from "localforage"; | |
import { ProfileServices } from '../../providers/profile.services'; | |
@Component({ | |
selector: 'page-profile', | |
templateUrl: 'profile.html', | |
providers: [ProfileServices] | |
}) | |
export class Profile { | |
public user: any; | |
public userProfile: any; | |
constructor(public navCtrl: NavController, private profile:ProfileServices, public params: NavParams, public storage: Storage, public loading:LoadingController ){ | |
this.getPerfilData(); | |
console.log("user profile"+this.userProfile); //Undefined | |
} | |
getPerfilData(){ | |
this.presentLoadingDefault(); | |
this.storage.get('user').then((user) => { | |
this.user = JSON.parse(user); | |
this.profile.getProfile("token", this.user.idUser ).subscribe( | |
(data) => { | |
this.userProfile = data; | |
console.log("user profile"+this.userProfile);//Data http success | |
}); | |
}); | |
} | |
presentLoadingDefault() { | |
let loading = this.loading.create({ | |
content: 'Please wait...' | |
}); | |
loading.present(); | |
setTimeout(() => { | |
loading.dismiss(); | |
}, 2000); | |
} | |
ionViewDidLoad() | |
{ | |
// this.getPerfilData(); | |
} | |
ionViewWillEnter() { | |
// this.getPerfilData(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment