Angular 5, HTML, boolean on checkbox is checked Angular 5, HTML, boolean on checkbox is checked typescript typescript

Angular 5, HTML, boolean on checkbox is checked


You can use this:

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

Here, record is the model for current row and status is boolean value.


When you have a copy of an object the [checked] attribute might not work, in that case, you can use (change) in this way:

<input type="checkbox" [checked]="item.selected" (change)="item.selected = !item.selected">