Can anyone assist me in figuring out what I am doing wrong when attempting to push data to an empty array?
I am trying to only add selected values (i.e. those with checked as true), but I can't seem to get inside the loop
This is the current condition:
const vals = [];
if (e && e.source.selected.length > 0) {
console.log('selected values', e.source.selected);
const sel = e.source.selected;
sel.forEach((e: any) => {
if (sel._selected) {
vals.push(e);
console.log('EE', e);
}
});
}
Check out the demo on StackBlitz
Expected output:
selectedList : [
{ id: '0' }, { id: '1' }, { id: '2' }
]
Purpose:
Attempting to bind the same data in edit mode within a form