My ngFor loop generates a series of checkboxes based on the X number of items in childrenList:
<div *ngFor="let child of childrenList; let indice=index">
<p-checkbox label="{{child.firstname}} {{child.lastname}}" binary="true" (onChange)="dentalChanged(indice, $event)" name="item-{{indice}}">
</p-checkbox>
</div>
I have successfully been able to detect when a checkbox is checked using the following code:
dentalChanged(indice: any, event: any): void {
alert(indice)
console.log(event.checked)
}
Now I am facing an issue where I need to save the selected items upon clicking a button. Since the number of elements in childrenList varies, I am unsure how to iterate through them from index 0 to n.
Your assistance is greatly appreciated.