Skip to content

Instantly share code, notes, and snippets.

@heobay
Forked from EpokK/ngEnter.js
Created January 8, 2014 02:20
Show Gist options
  • Select an option

  • Save heobay/8310654 to your computer and use it in GitHub Desktop.

Select an option

Save heobay/8310654 to your computer and use it in GitHub Desktop.
app.directive('ngEnter', 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