ion-toggle how to fire event when scoring

Asked

Viewed 304 times

1

I have following code:

<ion-item *ngFor="let dispositivo of dispositivos">
<ion-label>{{dispositivo.Nome}}</ion-label>
<ion-toggle toggle-class="toggle-positive" [(ngModel)]="dispositivo.Status" data-ng-change="acao(dispositivo)"></ion-toggle>

I want to shoot

acao(dispositivo: any) {

  //algo aqui

}

In this code it does not arrive at the event action.

1 answer

0

Midana,

Use ion-toggle Event Binding which is ionChange ie.

<ion-toggle toggle-class="toggle-positive" [(ngModel)]="dispositivo.Status" [ionChange]="acao(dispositivo)"></ion-toggle>

According to ionic2 documentation:

https://ionicframework.com/docs/v2/api/components/toggle/Toggle/

Remembering that you should probably check the current value of toggle.

Browser other questions tagged

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