Skip to content

Instantly share code, notes, and snippets.

@che-wf
Created May 25, 2015 20:42
Show Gist options
  • Save che-wf/f05087aeb73153818264 to your computer and use it in GitHub Desktop.
Save che-wf/f05087aeb73153818264 to your computer and use it in GitHub Desktop.
ngEnter
/* Directive for Hitting Enter for Search */
function ngEnter() {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if (event.which === 13) {
scope.$apply(function () {
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment