Pass-through id to another Ionic 3 page (Restful API with php)

Asked

Viewed 88 times

0

Good afternoon,
I’m making an application in Ionic 3 using the Restful API with php for connection to the MYSQL database and my app lists rooms of a house with its respective consumption, follows images of the app currently:

inserir a descrição da imagem aqui inserir a descrição da imagem aqui
inserir a descrição da imagem aqui

When I click on this View Details button I would like the id of the chosen room to pass to the other page, follow the codes:

Home.html

<ion-item-sliding *ngFor="let comodos of comodo">
  <ion-item>
    <ion-avatar item-start>
      <img src="../assets/img/ionic3-ico.png">
    </ion-avatar>
    <h2>{{(comodos.descricao)}}</h2>
  </ion-item>
  <ion-item-options side="left">
      <button ion-button color="dark">
          <ion-item class="transparente">
            <ion-icon name="flash" color="primary" item-left></ion-icon>
            <span>{{(comodos.potencia_atual)}} Wh</span>
          </ion-item>
      </button>
    </ion-item-options>
  <ion-item-options side="right">
    <button ion-button color="warning" (click)="doSearch(comodos.id)">
      <ion-icon name="home"></ion-icon>
      Ver Detalhes {{(comodos.id)}}
    </button>
  </ion-item-options>
</ion-item-sliding>

Home.ts

public doSearch(id_comodo) {
 this.nav.setRoot(TripsPage, {id: this.id});
}

1 answer

0


You did almost everything right, just passed the wrong id in setRoot, the right would be:

public doSearch(id_comodo) {
  this.nav.setRoot(TripsPage, {id: id_comodo});
}
  • is because this.id has stored the user id and I didn’t know how the comodo id passed, thanks for the reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.