Skip to content

Instantly share code, notes, and snippets.

@davutg
Created November 1, 2016 19:17
Show Gist options
  • Save davutg/f037894ab1ebc6f762d10e9dac945c0e to your computer and use it in GitHub Desktop.
Save davutg/f037894ab1ebc6f762d10e9dac945c0e to your computer and use it in GitHub Desktop.
evaluate something bound to onEnter attrib on enter
myApp.directive('onEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if (event.which === 13) {
scope.$apply(function () {
scope.$eval(attrs.onEnter);
});
event.preventDefault();
}
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment