I have this tr and td tag both have onclick event
<tr (click)="update(list.Item)" *ngFor="let list of List | paginate: { itemsPerPage: 10, currentPage: p };">
<td style="width:5%" (click)="delete(list.Item)">
<a title="Delete"><i class="icon-trash"
style="margin-right: 10px"></i></a>
</td>
</tr>
delete(itemID)
{
}
issue is when i click on td event then also tr event is getting called i want to restrict tr event click when td is clicked.
2
Answers
This issue is because the
<td>
is inside the<tr>
, then every time you push your<td>
the<tr>
event is called too, you can try to put the longpress option to the<tr>
and use the(click)
to the<td>
Like this:
You need to use
stopPropagation
to stop the event from bubbling upwards and triggering the other events!stackblitz