While I generally know how to use forEach
, I recently encountered a situation that left me puzzled. Even after searching online, I couldn't find any new information that could help.
I recently started delving into TypeScript due to my work with Angular. I managed to access a group of controls within the DOM and then proceeded to select one of them along with its children.
@ViewChildren("marker") markers: QueryList<ElementRef>;
this.markers.forEach(item => {
let element = item.nativeElement;
//item.children.forEach(child => {child.classList.add("poof"); });
for (let child of element.children)
child.classList.add("poof");
});
When looking at the console, it appears as an array due to the brackets, even though typeof
indicates it is an object.
I'm currently confused about this issue and also curious as to why the commented out code does not seem to be working. Unfortunately, I am unsure of what to search for to gain more insight into this matter.