Skip to content

Instantly share code, notes, and snippets.

@clouddueling
Created May 22, 2013 04:00
Show Gist options
  • Save clouddueling/5625160 to your computer and use it in GitHub Desktop.
Save clouddueling/5625160 to your computer and use it in GitHub Desktop.
listens for keypress enter only. great for textareas when you don't need ALL of angular-ui
directives.directive('ngEnter', function(){
return {
restrict: 'A',
link: function(scope, elem, attr, ctrl) {
elem.bind('keypress', function(e, ui){
if (e.keyCode == '13') {
scope.$apply(function(s) {
s.$eval(attr.ngEnter);
});
}
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment