Reputation: 25302
I have a custom directive which is applied to some element:
<table my-directive="eventName">
As part of the directive I emit the event:
scope.$emit(attr.myDirective)
The problem is in the event handler I need to access the element to which my directive was applied:
$scope.$on('eventName', function() {
$element???
});
I know modifying elements is not an Angular-way but at the moment it is what I need.
Upvotes: 0
Views: 100
Reputation: 474
Pass element as argument:-
scope.$emit(attr.myDirective, $element);
And use it inside listener
$scope.$on('eventName', function(event, element) {
//use element here
});
Upvotes: 1