Skip to content

Instantly share code, notes, and snippets.

@RajaJaganathan
Created September 19, 2015 09:07
Show Gist options
  • Save RajaJaganathan/01ce9172ad8f577def85 to your computer and use it in GitHub Desktop.
Save RajaJaganathan/01ce9172ad8f577def85 to your computer and use it in GitHub Desktop.
ngEnter directive utility
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