Hello I have problems with IONIC, every time I print console.log (this.items) it prints undefined, however console.log (data) prints without problems.
- Ionic App Scripts: 3.2.0
- Angular Core: 5.2.11
- Angular Compiler CLI: 5.2.11
- Node: 8.11.2
Note: I want to traverse that variable in the same controller, not in the view. I would greatly appreciate your help, regards.
export class AccederPage {
items:any;
usuario:String;
clave:String;
constructor(public navCtrl: NavController, public navParams: NavParams,public alertCtrl: AlertController, public http: HttpClient) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad AccederPage');
}
login(){
this.http.get("https://xxx.com/yyy/empleados").subscribe(
(data=>{
this.items=data;
console.log(data);
}),
(
error=>{
console.log(error);
}
)
);
console.log(this.items);