ion-toggle how to trigger event when dialing

0

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 action event.

    
asked by anonymous 21.03.2017 / 03:24

1 answer

0

Midana,

Use the ion-toggle event binding that is the ionChange ie.

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

According to ionic2 documentation:

link

Remembering that you should probably check the toggle's current value.

    
27.03.2017 / 22:30