import ngModule from '../module'; /* * Registers a handler for the click event and stops propagation when event * is thrown, mainly when nesting clickable elements wich ignore the * Event.defaultPrevented property, like ui-sref. */ export function directive($parse) { return { restrict: 'A', link: function(scope, element, attrs) { const fn = $parse(attrs.vnClickStop); element.on('click', function(event) { fn(scope, {$event: event}); event.stopPropagation(); event.preventDefault(); }); } }; } directive.$inject = ['$parse']; ngModule.directive('vnClickStop', directive);