GettingStarted
GettingStarted

Reputation: 7625

how can I programmatically set the checkbox to true or false?

      <label class="switch">
        <input type="checkbox" id="balanced" [(ngModel)]="balancedAmount" (click)="onNoClick($event)">
        <span class="slider round"></span>
      </label>

how can I programmatically set the checkbox to true or false?

TypeScript

  this.balancedAmount.checked = false;

Upvotes: 0

Views: 1312

Answers (1)

Abhishek Upadhyay
Abhishek Upadhyay

Reputation: 37

You can create a variable and toggle true or false and you can property bind that value to the [checked] property

 <label class="switch">
        <input type="checkbox" id="balanced" [(ngModel)]="balancedAmount" (click)="onNoClick($event)" [checked]="this.balancedAmount.checked">
        <span class="slider round"></span>
      </label>

this.balancedAmount.checked= true;

Upvotes: 1

Related Questions