Nested ng-click & $event.stopPropagation()

I'm trying to cancel propagation inside a nested ng-click event.

$scope.cancel = function($event){
   $event.stopPropagation();
}

Relevant View Code:

<tbody>
  <tr ng-click="goTo(1)">
    <td class="col-md-1">{{ client.code }}</td>
    <td class="col-md-5">{{ client.name }}</td>
    <td class="col-md-2">{{ client.telephone }}</td>
    <td class="col-md-2">{{ client.fax }}</td>
    <td class="col-md-2"><a href="mailto:{{client.email}}" ng-click="cancel($event)">{{client.email}}</a></td>
  </tr>
</tbody>

Here's a plunker: http://plnkr.co/edit/dxgfK41Dp1Gs2DCmeFcw?p=info

Why doesn't it work?

Answers


It's not working because $event is undefined if you don't pass $event from the view:

Add this to your view:

<td class="col-md-2"><a href="mailto:{{client.email}}" ng-click="cancel($event)">{{client.email}}</a></td>

Here's your updated plunkr with propagation stopped: http://plnkr.co/edit/ywvPcO01C0fgzvpxRnf9?p=info


Need Your Help

Is Garbage Collection time related to number of objects or size of objects?

java memory garbage-collection heap heap-memory

I am having an issue with slow garbage collection. Obviously, the more objects in heap (all else equal) will lead to longer GC time, and larger sized objects in heap will lead to longer GC times.