Good, I am trying to show the data when loading the page in ionic my code below I show you my code I would like to please know what my error is:
Page TS:
mport { Component,OnInit } from '@angular/core';
import { IonicPage, NavController, NavParams,AlertController,LoadingController } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { PlayersProvider } from '../../providers/players/players';
/**
* Generated class for the ProfilePage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-profile',
templateUrl: 'profile.html',
})
export class ProfilePage {
public perfil:any;
constructor(public navCtrl: NavController, public navParams: NavParams,
public alertCtrl:AlertController,
public _players:PlayersProvider,
public loadingCtrl:LoadingController) {
}
ngOnInit(){
let loading = this.loadingCtrl.create({
content: 'Please wait...'
});
// Mostramos el loading
loading.present();
this._players.get_my_detail(4)
.subscribe((response)=>{
console.log("Perfil",response);
this.perfil=response;
loading.dismiss();
});
}
presentLoadingDefault() {
let loading = this.loadingCtrl.create({
content: 'Please wait...'
});
loading.present();
setTimeout(() => {
loading.dismiss();
}, 1000);
}
ionViewDidLoad() {
console.log('ionViewDidLoad ProfilePage');
}
}
And good in the view when I want to show the following:
<ion-col col-6 class="full-name">
<div class="content-full-name">
LOZADA CHIRA <br>
<span class="name">{{perfil.data.name}}</span>
</div>
</ion-col>
It tells me that the data variable is undefined: nevertheless in my console the answer is the following:
enter the code here
Perfil
{status: true, data: {…}}
data
:
address
:
"axaxacbhdcb"
created_at
:
null
dni
:
"70000052"
email
:
"[email protected]"
foot
:
2
height
:
2
id
:
4
lastname
:
"Llamsas"
logical_delete
:
0
name
:
"Raul"
phone
:
"992825491"
photo
:
"59f8e51faec68.jpg"
type
:
1
updated_at
:
"2017-10-31 21:03:28"
weight
:
98
__proto__
:
Object
status
:
true
__proto__
:
Object