0
<li ng-click="function()">
<div class="child">
<a href="#">something</a>
</div>
</li>

How to avoid function() been trigger when I click on a or .child? I know in jquery we do e.preventDefault(). But how about angularjs?

Jessica Illy
  • 67
  • 1
  • 2
  • 7
  • You do the exact same thing in Angular. Put an ng-click on the `div`, make it take `$event` (exact wording) as a parameter and call `preventDefault()`. Ie., `
    ` where `onClick = (event) => event.preventDefault()`
    – Dan Sep 11 '16 at 12:35
  • 1
    You don't do `e.preventDefault()` in `jQuery`, it's javascript. That's just a function you can call on any object of native event type. In angular it's exactly the same, since it's just "normal" javascript which gets executed on a `ngClick`. you just have to pass the event along with it (`ngClick="myFunc($event)"`) so it gets available in your declaration. – malifa Sep 11 '16 at 12:36

0 Answers0