I have a function that requires the $event obj to be passed into as a parameter. The function works just fine when I call it using ng-click. However, now I am told to change the function into a custom directive. But now I don't know how to access the $event object every time the element containing the custom directive gets clicked. Any suggestions? I have this so far but console logging is giving me undefined.
(function () {
angular.module(APPNAME)
.directive('clickTracker', clickTracker);
function clickTracker() {
return {
scope: true,
link: function (scope, element, attrs) {
element.bind('click', function () {
var mouseEvent = scope.$eval(scope.$event);
console.log(mouseEvent);
}
}
}
}
})()