Created
June 27, 2014 07:39
-
-
Save srfrnk/7397da5d001d2316a2d0 to your computer and use it in GitHub Desktop.
NG directive to disable click event from bubbling up...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define("directives/captureClick", ["app"], function (app) { | |
return app.directive('captureClick', [function () { | |
return { | |
restrict: "A", | |
controller: ["$scope", "$element", "$attrs", "$transclude", function ($scope, $element, $attrs, $transclude) { | |
$element.click(function (e) { | |
e.stopPropagation(); | |
}); | |
}] | |
}; | |
}]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use when you have an inner element nested within a larger container and you need to have ng-click handled differently for the inner and outer elements. (to prevent every click on the inner child bubbling and also triggering the parent!)
Usage:
<.... capture-click ></...>