Skip to content

Instantly share code, notes, and snippets.

@chrisjordanme
Created January 8, 2015 17:30
Show Gist options
  • Save chrisjordanme/2f2020a0b3d65ddac0c9 to your computer and use it in GitHub Desktop.
Save chrisjordanme/2f2020a0b3d65ddac0c9 to your computer and use it in GitHub Desktop.
Angular Directive to Bind Event handler to transcluded DOM and then $broadcast events
angular.module('myApp')
.directive('myAppTrigger', function () {
return {
restrict: 'C',
transclude: true,
replace: true,
template: '<div ng-transclude></div>',
link: function (scope, el, attrs) {
el.on('click', function () {
scope.$broadcast(attrs.eventType || 'activated');
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment