Skip to content

Instantly share code, notes, and snippets.

@Werninator
Forked from EpokK/ngEnter.js
Last active March 3, 2016 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Werninator/2fdcd7757bfd997496ee to your computer and use it in GitHub Desktop.
Save Werninator/2fdcd7757bfd997496ee to your computer and use it in GitHub Desktop.
ngEnter directive for AngularJS
app.directive('ngEnter', function() {
return function(scope, element, attrs) {
element.bind('keydown keypress', function(event) {
if (event.which !== 13)
return;
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