Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. // ng-enter="myFunction()"
  2. app.directive('ngEnter', function () {
  3. return function (scope, element, attrs) {
  4. element.bind("keydown keypress", function (event) {
  5. if(event.which === 13) {
  6. scope.$apply(function (){
  7. scope.$eval(attrs.ngEnter);
  8. });
  9.  
  10. event.preventDefault();
  11. }
  12. });
  13. };
  14. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement