Function in Ionic 3

Asked

Viewed 363 times

0

I’m doing a file function TS page, but would need to capture HTML information to make a conditional push(navCtrl) for each option...

The list on which I need to get the information and the code:

<ion-list>
      <ion-item>
        <ion-label>Ocupação</ion-label>
        <ion-select [(ngModel)]="ocupacao">
          <ion-option value="dir" >Diretor(a)</ion-option>
          <ion-option value="prof">Professor(a)</ion-option>
          <ion-option value="res">Responsável</ion-option>
          <ion-option value="sec">Secretária</ion-option>
        </ion-select>
      </ion-item>
    </ion-list>

1 answer

0


With two-way data Binding you can access the variable in . ts like this.occupation, so let’s say that when calling a Ubmit the onsubmit function below is executed

onSubmit = () =>{
  //acessando à variável ocupacao
  console.log(this.ocupacao);
  if(this.ocupacao == 'dir')
     this.navCtrl.push(DirPage);
}
  • thank you very much !!

Browser other questions tagged

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