enter.js 355 B

12345678910111213141516
  1. 'use strict';
  2. angular.module('etcdControlPanel')
  3. .directive('ngEnter', function() {
  4. return function(scope, element, attrs) {
  5. element.bind('keydown keypress', function(event) {
  6. if(event.which === 13) {
  7. scope.$apply(function(){
  8. scope.$eval(attrs.ngEnter);
  9. });
  10. event.preventDefault();
  11. }
  12. });
  13. };
  14. });