I have included a button into the table row. but i want to handle onClick event for them separately. But when i click the button the table row click event is also getting fired. How to only fire only the button click element when button is clicked. Here is the code i'm using currently
<table class="table" style="width:100%;">
<div *ngFor="let data of Data; let j = index;">
<tr [ngClass]="{onClickMember: data .clicked}" (click)="addData(data , j)">
<td width="15%">{{member.name}}</td>
<td width="15%"><button class="role-toggle" (click)="changeData(data , j)">{{data .role}}</button></td>
</tr>
</div>
</table>
You can pass special $event
object in your (click) function.
<button class="role-toggle" (click)="changeData($event, data , j)>
Catch the event in code and stop propogation
changeData(event, data, j) {
event.stopPropagation()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With