'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;


Solution 1:[1]

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;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abhishek Upadhyay