如何在离子2中的选择项目中加载数据并知道所选项目?

时间:2017-04-22 19:11:31

标签: ionic2 items

我目前的尝试

page.html中

<form (ngSubmit)="InsertLocation()" #registerForm="ngForm">
     <ion-row>
        <ion-col>
             <img src="assets/img/1.jpg" />
              <ion-list>
                  <ion-item>
                     <ion-label>Chauffeur</ion-label>
                     <ion-select [(ngModel)]="selectedvalue"name="chauff">
                         <ion-option *ngFor="let item of chauffeurs"[value]="item.nom_chauffeur">
                         {{item.nom_chauffeur}}
                         </ion-option>
                     </ion-select>
                   </ion-item>
            <ion-list>
         <ion-row>
       <ion-col>
       <button ion-button class="submit-btn" type="submit" 
       [disabled]="!registerForm.form.valid">Inserer</button>
</form>

page.ts

  LoadChauffeurs(id){
  this.data.LoadChauffeur().subscribe(
      data => {
          this.chauffeurs= data; 
      },
      err => {
          console.log(err);
      },
      () => console.log('success!')
  );
}

知道数据的结果是像这样的数组

[{
     "id_chauffeur":6,
      "nom_chauffeur":"ggg", 
      "num_tel":2563,"id_chef":10
}]  

以及我在page.ts中称之为数据的服务 的数据service.ts

LoadChauffeur(id) {

  var url = 
   'http://localhost/PFEBACKEND/retrievechauffeurs.php?'key=random&id='+id;
      var response = this.http.get(url).map(res => res.json());
      return response;

 }

this the result i get

0 个答案:

没有答案