Skip to content

Instantly share code, notes, and snippets.

@toddbranch
Last active September 28, 2015 16:54
Show Gist options
  • Select an option

  • Save toddbranch/fe11cdbbdc9ae5c9aec3 to your computer and use it in GitHub Desktop.

Select an option

Save toddbranch/fe11cdbbdc9ae5c9aec3 to your computer and use it in GitHub Desktop.
Angular focusOnClick Directive
angular.module('gmail').directive('focusOnClick', [
function() {
return {
restrict: 'A',
link: function($scope, $el, attrs) {
function focusOnClick() {
// Note: selector must uniquely identify the element in the page
$(attrs.focusOnClick).focus();
}
$el.on('click', focusOnClick);
$el.on('$destroy', function() {
$el.off('click', focusOnClick);
});
}
}
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment