Ion-select does not work as it should

Asked

Viewed 333 times

0

I have the following code for ion-select:

<ion-item class="drop-categoria" style="margin-bottom: 5%; ">
  <ion-label>Categorias</ion-label>
  <ion-select [(ngModel)]="catselected" (ng-change)="onChange(catselected)">
    <ion-option *ngFor="let cat of categorias" [value]="cat.nome" >{{ cat.nome }}</ion-option>
  </ion-select>
</ion-item>

And no . ts:

  onChange(catselected){
    console.log(catselected);

    }

I need to get the selected amount in case the cat.nome, but when I click OK, nothing occurs, no error, and no response, which may be?

1 answer

1


For me it worked like this:

<ion-item class="drop-categoria" style="margin-bottom: 5%; ">
  <ion-label>Categorias</ion-label>
  <ion-select [(ngModel)]="cati" (ionChange)="onChange(cati);">
    <ion-option *ngFor="let cat of categorias" [value]="cat.nome" >{{ cat.nome }}</ion-option>
  </ion-select>
</ion-item>

and in the . ts

  onChange(){
    console.log(this.cati);

    }
  • this way worked very well here for me, thank you!

Browser other questions tagged

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