Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude an element from ng-click action

I have an element inside a container with ng-click, that should not execute this click action. It has the structure similar to this:

<div class="container" ng-click="takeSomeAction()>
    <p>Some content</p>
    <a class="btn" ng-href="#{{whatever}}">button content</a>
</div>

How to prevent executing takeSomeAction() when you click the button?

like image 334
Frizi Avatar asked Jul 15 '13 19:07

Frizi


1 Answers

You need to stop the event propagation, which can be done very easily with another ng-click.

<div class="container" ng-click="takeSomeAction()>
    <p>Some content</p>
    <a class="btn" ng-href="#{{whatever}}" ng-click="$event.stopPropagation()">button content</a>
</div>

It will prevent the routine execution while following the href.

like image 89
Frizi Avatar answered Nov 16 '22 23:11

Frizi