Fábio Heitor
Fábio Heitor

Reputation: 105

Is there an option to ion-toggle change a variable value with its properties

I cant make a variable change using a function with ion-toggle, but i want to know if theres any way with ion-toggle properties, to change the value of an variable when the the toggle is pressed (without using functions).

I tried checked, value, change, ngModel, but i cant make a variable to change when the button is pressed.

  <ion-toggle slot="end" 
checked="test" 
[ngModel]="test" 
(click)="changeTest()" ></ion-toggle>

The variable test is by default true, so the button starts active, and i want to change the value of test when i press the button, without using functions, because with functions i alrady did it (changeTest())

Thanks

Upvotes: 1

Views: 4229

Answers (1)

Hamza Meghlaoui
Hamza Meghlaoui

Reputation: 146

use the ionChange event

<ion-toggle slot="end" 
checked="test" 
[ngModel]="test" 
(ionChange)="changeTest()" ></ion-toggle>

Upvotes: 2

Related Questions