Skip to content

Instantly share code, notes, and snippets.

@kidker
Forked from EpokK/ngEnter.js
Created February 25, 2016 16:57
Show Gist options
  • Save kidker/cf02349ff688217760bf to your computer and use it in GitHub Desktop.
Save kidker/cf02349ff688217760bf to your computer and use it in GitHub Desktop.
ngEnter directive if you can use submit form(https://twitter.com/ririlepanda)
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