Angular ForEach in Angular4/Typescript?
in angular4 foreach like that. try this.
selectChildren(data, $event) {
let parentChecked = data.checked;
this.hierarchicalData.forEach(obj => {
obj.forEach(childObj=> {
value.checked = parentChecked;
});
});
}
you can try typescript's For
:
selectChildren(data , $event){
let parentChecked : boolean = data.checked;
for(let o of this.hierarchicalData){
for(let child of o){
child.checked = parentChecked;
}
}
}
arrayData.forEach((key : any, val: any) => {
key['index'] = val + 1;
arrayData2.forEach((keys : any, vals :any) => {
if (key.group_id == keys.id) {
key.group_name = keys.group_name;
}
})
})