Cancel event propagation between nested ng-click calls


#1

What does ion-stop-event do? I can’t seem to find the code for it.

I want to cancel event propagation between nested ng-click calls. Is there an ionic prebuilt function?

Here are my current solution:

.directive('stopEvent', function () {
    return {
        restrict: 'A',
        link: function (scope, element, attr) {
            element.bind('click', function (e) {
                e.preventDefault(); // added for ionic
                e.stopPropagation();
            });
        }
    };
});

#2

Hm, the directive you have here seems to work fine here, swipe open the list item and tap Cancel Event

Could you provide a more accurate example to your situation?


#3

My directive works fine. While doing research I found ion-stop-event and was wondering if it did the same thing. Therefore, I could use it instead of my version.


#4

You know that is a good question. There isn’t any documentation but from the looks of the code, I’m guessing it’s just a utility directive.

Don’t see anything stopping you from using it.


#5

I’ve also noticed this isn’t in the docs, and would like to see it there.


#6

Seems that this directive originated here : https://github.com/driftyco/ionic/issues/550

adding ion-stop-event="click" does the trick.

Hope this helps !