I have the following 3 input checkboxes, after checking the checkboxes, I would like to clear all the checked items after the "Clear Checkbox" button is clicked. I attempted the following but it doesn't work.
app.component.html
<ul *ngFor="let d of data">
<li>
<input id="checkbox" type="checkbox" class="checkbox" />
{{ d }}
</li>
</ul>
<button (click)="myFunction()">Clear Checkbox</button>
app.component.ts
export class AppComponent {
data = ['tea', 'coffe', 'soda'];
public myFunction() {
(<HTMLInputElement>document.getElementById('checkbox')).checked === false;
}
}
<HTMLInputElement>document.getElementById('checkbox')).checked = false, With===, you are making a comparison.