AngularJS ng-click 停止傳播 - AngularJS ng-click stopPropagation

問題:

I have a click Event on a table row and in this row there is also a delete Button with a click Event.我在表格行上有一個點擊事件,在這一行中還有一個帶有點擊事件的刪除按鈕。 When i click the delete button the click Event on the row is also fired.當我單擊刪除按鈕時,該行上的單擊事件也會被觸發。

Here is my code.這是我的代碼。

<tbody>
  <tr ng-repeat="user in users" class="repeat-animation" ng-click="showUser(user, $index)">
    <td>{{user.firstname}}</td>
    <td>{{user.lastname}}</td>
    <td>{{user.email}}</td>
    <td><button class="btn red btn-sm" ng-click="deleteUser(user.id, $index)">Delete</button></td>
  </tr>
</tbody>

How can I prevent that the showUser Event is fired when i click the delete Button in the table cell?當我單擊表格單元格中的刪除按鈕時,如何防止觸發showUser事件?


解決方案:

參考一: https://en.stackoom.com/question/1NBBK
參考二: https://stackoom.com/question/1NBBK
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章