How to set checkbox checked value with Angular and JavaScript?

Spread the love

To set checkbox checked value with Angular and JavaScript, we set the [checked] attribute.

For instance, we write

<input
  type="checkbox"
  [checked]="record.status"
  (change)="changeStatus(record.id, $event)"
/>

to set the [checked] attribute to the record.status property.

And we set the change evennt listener to call changeStatus to update the record.status property to the latest checked value when it’s changed.

Leave a Reply

Your email address will not be published. Required fields are marked *