Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonocairns/da071b3f1326e8357eee to your computer and use it in GitHub Desktop.
Save jonocairns/da071b3f1326e8357eee to your computer and use it in GitHub Desktop.
'use strict';
module app.common {
export function stopEvent(): ng.IDirective {
return {
restrict: 'A',
link: (scope: any, element: any) => {
element.bind('click', (event: any) => {
// other ng-click handlers shouldn't be triggered
event.stopPropagation(event);
});
}
};
}
angular
.module('app.common')
.directive('stopEvent', stopEvent);
}
// usage
// <button><button stop-event></button></button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment