Check out example codes for "angular closest element". It will help you in understanding the concepts better.

Code Example 1

constructor(private elRef: ElementRef){}

ngOnInit() {
   const parentElement = this.elRef.nativeElement.closest('.parent-element-class')
}

Learn ReactJs, React Native from akashmittal.com