I have a component and i have the following elements in component's html and need the element's id on clicking it. Example: on clicking
<div class="col-md-6 col-xl-6 col-sm-6">
<ul>
<li id = "l1">name1</li>
<li id = "l2">name2</li>
<li id = "l3">name3</li>
<li id = "l4">name4</li>
</ul>
</div>
I am trying to read id of each
@ViewChild('li', {read: ViewContainerRef}) showAllData;
@HostListener("click") onClick(){
console.log( $(this.showAllData.nativeElement).attr('id'));
}