Nested ng-click & $ event.stopPropagation ()

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

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

      

Corresponding code like:

<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 the plunker: http://plnkr.co/edit/dxgfK41Dp1Gs2DCmeFcw?p=info

Why isn't it working?

+3


source to share


1 answer


It doesn't work because $ event is undefined unless you pass $ event from the view:

Add this to your opinion:



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

      

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

+3


source







All Articles