Skip to content

Instantly share code, notes, and snippets.

@travisj
Last active December 14, 2015 18:48
Show Gist options
  • Save travisj/5131714 to your computer and use it in GitHub Desktop.
Save travisj/5131714 to your computer and use it in GitHub Desktop.
myApp.directive('onEnter', function() {
return function($scope, element, attrs) {
element.bind('keydown keypress', function(e) {
if (e.which === 13) {
$scope.$apply(function() {
$scope.$eval(attrs.onEnter);
});
e.preventDefault();
}
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment