Skip to content

Instantly share code, notes, and snippets.

@vanckruz
Created November 7, 2016 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanckruz/92d6ea6ac114e6d28e88eb22caddc82a to your computer and use it in GitHub Desktop.
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?
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