Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS ng-click on table row but not on a certain td

I'm facing an issue when there is an event data-ng-click on table row, but i want that a certain td won't do the event in the row.

is it possible to do it?

if so, how?

example html:

      <table>
          <tr data-ng-click="do_some_action()">
              <td>
                  cell 1 is clickable
              </td>
              <td>
                  cell 2 is clickable
              </td>
              <td class="not-clickable-cell">
                  cell 3 is not! clickable
              </td>
          </tr>
      </table>
like image 318
Liad Livnat Avatar asked May 27 '14 12:05

Liad Livnat


1 Answers

You can stop event propagation like this:

<td class="not-clickable-cell" ng-click="$event.stopPropagation()">
    cell 3 is not! clickable
</td>

so that when you click this cell event will not bubble up to the tr event handler.

Demo: http://plnkr.co/edit/jvh5NKaDsvpPKuSJhzFx?p=preview

like image 154
dfsq Avatar answered Oct 22 '22 07:10

dfsq