Ionic 2如何检索列表中的信息?

时间:2017-01-28 14:27:19

标签: ionic2

我正在尝试从我的PHP服务器检索信息。

这是我的代码

//Dans mon service d'authentification
checkVehicleList() {
    this.getUserId().then(data => {
    this.userid = data; 
    return new Promise(resolve => {
        alert(this.userid);
        this.http.get('http://localhost/helloworld/api/v1/list?iduser='+this.userid).subscribe(data => {
            alert(data.json().InformationsVehicules);
           if(data.json().InformationsVehicules){
                alert("reussite");
           } else { alert("error !") }
             });
        });
    });
}

//Dans la page des vehicules, j'appel la fonction juste pour savoir ce qu'elle qaffiche avec les alerts
public MarqueVeh : any;
public marque : any;

loadVeh() {
  this.viauth.checkVehicleList().then(data => {
    this.MarqueVeh = data;
  });
}


// Voici le tableau que me retourne ma route PHP
{"InformationsVehicules":[{"marque":"bgy","matricule":"ce1370","numero_chassi":"123654"},{"marque":"bvd","matricule":"derty","numero_chassi":"ddff"}]}

我希望返回的数组保存在变量中,以便我可以像这样使用它

<ion-button button round class="veh-button" clear color="light" (click)="showVehiclePopUp()">{{Veh.marque}}<span style="display:inline-block; width: 200px;"></span>

<ion-buttons end>
  <ion-icon name="ios-play"></ion-icon>
</ion-buttons></button><br> 

我将警报放在我的代码中以了解变量包含的内容,并收到消息“未定期”。

0 个答案:

没有答案