mardi 7 mars 2023

In Angular 14 and PrimeNG, how do I get the state of a checkbox in the click handler?

I'm using PrimeNG and Angular 14. I have a checkbox in my p-table

<p-tableCheckbox (click)="onSelectAll($event)"></p-tableCheckbox>

I would like to know if the state of the box is checked or unchecked. So I tried

onSelectAll(event: any) { if (event.checked) { this.selectedCustomers = this.customers.slice(); // select all } else { this.selectedCustomers = []; // unselect all } }

but "event.checked" is repeatedly undefined. I also tried "event.target.checked" but to no avail. How do I tell if my checkbox is checked or not?




Aucun commentaire:

Enregistrer un commentaire