get the current element
angularjs
Solution
With a directive in angular it is easy to access the element. Just use the link function:
angular.module('myModule', [], function ($compileProvider) {
$compileProvider.directive('distortThatDiv', function distortThatDivDirective() {
return {
restrict: 'A',
link : function (scope, element, attrs) {
element.on('click', function () {
// do something
});
}
};
});
});
Your html would be:
<div ng-controller='myController'>
<a distort-that-div>My link</a>
</div>
Problem
It's possible to intercept current event object in `ng-click` like handlers by using `$event` property. But is it possible to get the element from which the method has been called? like for example: ``` <div ng-controller='myController'> <div>{{distortThatDiv($element)}}</div> </div> ```