Skip to content

Instantly share code, notes, and snippets.

@karimsa
Forked from EpokK/ngEnter.js
Last active August 23, 2016 00:07
Show Gist options
  • Save karimsa/b1b9ed48e2f03510559a2be6c4d4f948 to your computer and use it in GitHub Desktop.
Save karimsa/b1b9ed48e2f03510559a2be6c4d4f948 to your computer and use it in GitHub Desktop.
ngEnter directive if you can use submit form(https://twitter.com/ririlepanda)
app.directive('ngEnter', () => ($scope, $elm, $attrs) => {
$elm.bind('keydown keypress', evt => {
if ( evt.which === 13 ) {
$scope.$apply(() => $scope.$eval($attrs.ngEnter));
evt.preventDefault();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment