Ich habe ein Problem eine Variable erstellt in ionViewDidLoad in einem ts innerhalb meiner app zugreifen.Zugang Variable in ionViewDidLoad (Ionic 3)
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Http } from '@angular/http';
import { CarreerDataProvider } from '../../providers/carreer-data/carreer-data';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
clientName = "hola";
carrera={
kind: 'key'
}
modeKeys = [
{'key':"pablo","precio":"500","precio2":"500"},
{'key':"juan","precio":"500","precio2":"500"},
{'key':"lili","precio":"500","precio2":"500"},
{'key':"juan","precio":"500","precio2":"500"},
{'key':"juan","precio":"500","precio2":"500"},
]
constructor(public navCtrl: NavController,public carreerService: CarreerDataProvider, public http: Http) {
console.log("constructorLoading");
}
ionViewDidLoad(){
var jlink = 'http://nimbler.app-senescyt.sachiel.xyz/universidad-rest';
var getItem = function(ids) {
console.log('hola');
console.log(ids);
return ids;
};
//Auto Json
var getJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "json";
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
callback(null, xhr.response);
}
else {
callback(status);
}
};
xhr.send();
};
//start Json
getJSON(jlink, function(err, data) {
if (err != null) {
console.log('No wiki data code found');
}
else {
var i =0;
var total = Object.keys(data).length;
var ids = [];
for(i; i < total; i++) {
if (ids.indexOf(data[i].field_provincia) == -1) {
ids.push(data[i].field_provincia);
}
}
// Start axctionable code.
getItem(ids);
// End actionable code.
}
});
}
ionViewDidEnter(){
console.log("IonViewEnter");
}
}
Die Variablen carrera
und modeKeys
sind localy eine ion-select
im HTML-bevölkern verwendet. Was ich tun möchte, ist das Array verwendet ids
in ionViewDidLoad
aus einem Webservice erstellt diese ion-select
zu füllen, wie ich mit modeKeys
tun. Ich habe viele Methoden ohne Erfolg ausprobiert.
Hoffe, dass Sie mich mit meinem Problem helfen kann. Sehr geschätzt.
Geist Detaillierung mehr? Ich bin ein Neuling in Ionic. Vielen Dank! –