html - 如何使链接的表格行可点击,但最后一列的行为不同?
问题描述
下面是我正在使用的代码,它演示了我想要实现的目标
<tr *ngFor="let plan of list; index as i" class="success" (click)="platDetails(plan)">
<!-- the click event above takes us to the platDetails view-->
<td>{{plan.name}}
</td>
<td>{{plan.test}}
</td>
<td> <!-- I want to allow the user to click the dropdown btn without triggering the (click) event above. currently when i try to click this drop down the click event in the tr is triggered and takes me away. -->
<div class="input-group">
<button type="button" class="btnTransparent" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
<i class="fa fa-ellipsis-h"></i>
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" (click)="action(plan)">View Plan</a>
</div>
</div>
</td>
</tr>
如何拆分此 tr 以允许这两个 td 或多少个 td 由 tr click 事件控制并保留最后一个 td 自己?我希望这是有道理的。
解决方案
将platDetails
点击事件从行移动到列并离开最后一列
<tr *ngFor="let plan of list; index as i" class="success">
<!-- the click event above takes us to the platDetails view-->
<td (click)="platDetails(plan)">{{plan.name}}
</td>
<td (click)="platDetails(plan)">{{plan.test}}
</td>
<td> <!-- I want to allow the user to click the dropdown btn without triggering the (click) event above. currently when i try to click this drop down the click event in the tr is triggered and takes me away. -->
<div class="input-group">
<button type="button" class="btnTransparent" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
<i class="fa fa-ellipsis-h"></i>
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" (click)="action(plan)">View Plan</a>
</div>
</div>
</td>
推荐阅读
- flutter - 如何拥有需要用户 ID 的流提供程序?
- java - 使用 url android studio (Java) 设置壁纸
- f# - F# CsvProvider MissingMethodException
- javascript - 在一个 WordPress 主题上调整浏览器窗口的大小以及添加 JS 代码移动菜单关闭按钮后,导航栏不起作用
- scala - 惰性 val 如何解决前向引用扩展 scala 中的值定义
- python - 带有额外空格的 CSV
- sql - Firebase BigQuery,在触发“app_remove”之前获取 event_name
- javascript - 如何使用简单的 html 在 textarea 中保留换行符?
- ios - 无法在 iOS 设备上发送 UDP 广播 - NWConnection
- google-cloud-platform - 使用 Google 自然问题 (NQ) 数据集