Skip to content

Instantly share code, notes, and snippets.

@hyyan
Forked from EpokK/ngEnter.js
Last active August 29, 2015 14:15
Show Gist options
  • Save hyyan/a906adf9ac7f0c85b6b4 to your computer and use it in GitHub Desktop.
Save hyyan/a906adf9ac7f0c85b6b4 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.ngEnter);
});
event.preventDefault();
}
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment