Skip to content

Instantly share code, notes, and snippets.

@jose-marin
Forked from EpokK/ngEnter.js
Last active August 11, 2016 15:02
Show Gist options
  • Save jose-marin/249b7599cf8082b4173ea0047a67d013 to your computer and use it in GitHub Desktop.
Save jose-marin/249b7599cf8082b4173ea0047a67d013 to your computer and use it in GitHub Desktop.
ngEnter directive if you can use submit form(https://twitter.com/ririlepanda)
app.directive('onEnter', function() {
return {
restrict: "A",
scope: {
action: "&onEnter"
},
link: function(scope, element, attrs) {
element.on("keydown keypress", function(event) {
if(event.which === 13) {
scope.$apply(scope.action);
event.preventDefault();
}
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment