3

I have a link that uses ng-click inside of a table row which also uses the ng-click directive.

When I click on the link, both ng-click directives fire. How can I adjust them so that only the most specific one (remove item) fires?

 <tr ng-repeat="item in items" ng-click="viewItem(item.id)">
   <td>{{ item.name }}</td>
   <td><a ng-click="removeItem(item.id, 'item.name')">Remove item</a></td>
 </tr>

Thanks!

1
  • Could you provide a fiddle or something? Commented Aug 21, 2013 at 3:44

1 Answer 1

6

You just need to stop the event from bubbling by using stopPropagation().

<tr ng-repeat="item in items" ng-click="viewItem(item.id)">
   <td>{{ item.name }}</td>
   <td><a ng-click="removeItem(item.id, 'item.name'); $event.stopPropagation()">Remove item</a></td>
 </tr>

jsFiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.