dimanche 26 novembre 2023

Toggle button how to return true if it is ON and false if is OFF

Newbie to front-end world i am trying to implement a logic when a toggle button is on i want to return True and when it is turned off i want to return False

Below is my HTML

 <div class="toggle-button">

    <body>
      <label class="showLabel" for="show">Toggle on or off :</label>
      <label class="toggle">
        <input class="toggle-input" type="checkbox" (click)="helper();" />
        <span class="toggle-label" data-off="OFF" data-on="ON"></span>
        <span class="toggle-handle"></span>
      </label>
    </body>
  </div>

</div>

in typescript i have global variable that i want to be filled with either true or false when toggle is turned on or off -

Typescript global variable -

isToggled=false (if toggle is off)

or

isToggled=true (if toggle is on)

I would appreciate any help




Aucun commentaire:

Enregistrer un commentaire