[英]Angular - button click event take priority over row click event
Having a table with rows, I can click on a row to access the details of one row via a seperate page. 有了一个包含行的表格,我可以单击一行以通过单独的页面访问一行的详细信息。 This is done via the [routerlink].
这是通过[routerlink]完成的。
<tr *ngFor="let setting of applicatieData.settings" [routerLink]="['/settings-edit', setting.id]">
<td class="col-3">{{ setting.shortName | slice:0:10 }}</td>
<td class="col-4">{{ setting.value }}</td>
<th class="col-3"><button class="btn btn-info" type="button" (click)="toggleValue(setting.id)">Toggle</button></th>
<td class="col-2" (contextmenu)="onrightClick($event, setting.id)"><i class="icon-ellipsis-vert"></i></td>
</tr>
I would like the 'Toggle' button click event to take priority over previously mentioned row click event. 我希望“切换”按钮单击事件比前面提到的行单击事件具有更高的优先级。 How can I do that?
我怎样才能做到这一点?
The right click with the 'context menu' works fine. 右键单击“上下文菜单”可以正常工作。
you need to stop the event from bubbling up the dom tree. 您需要阻止事件使dom树冒起。
<th class="col-3"><button class="btn btn-info" type="button" (click)="toggleValue($event, setting.id)">Toggle</button></th>
toggleValue(event: MouseEvent, id: string) {
event.preventDefault();
event.stopPropagation();
...
}
you can try this 你可以试试看
<tr> <td class="col-3" (click)="clickFila()">1</td> <td class="col-4" (click)="clickFila()">2</td> <th class="col-3" (click)="clickFila()">3</th> <td class="col-2"(click)="clickColumna()">4</td> </tr>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.