Jul 26, 2021
0
Level 2
Detect if nested child element is contained by parrent element in typescript
Trying to detect if click event.target is child of an element
@viewChild('parentEl', {static: true} ) parentElement: ElementRef;
this.renderer.listen('window','click', (e: Event) => {
console.log(this.parentElement.nativeElement.contains(e.target));
}
When we click on the nested child element console logs false yet the parent element contains the nested child. So it is suppose to log true. Am i missing something?
Please or to participate in this conversation.