In my custom directive, I am binding focus
and click
events to an element:
app.directive('mydirective', function () {
return {
link: function ($scope, $element, $attrs) {
$element.bind('click focus', function (e) {
foo(e);
});
}
};
});
I want the function foo
to be called only once when either the focus
or click
event is triggered. However, on clicking the element, both the focus
and click
events fire, causing foo
to be called twice. Is there a way to prevent foo
from being called the second time?
Edit: I realize now that mixing hover with click and focus was not a good idea. Thank you all for your input.