Created
January 8, 2015 17:30
-
-
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
This file contains hidden or 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
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