<input type="text" ng-model="employee.account" ng-keydown />
js:
/*directives*/ angular.module('activitiModeler').directive('ngKeydown',function() { return { restrict: 'A',link: function(scope,elem,attrs) { //var functionToCall = scope.$eval(attrs.ngKeydown); elem.on('keydown',function(e){ alert(e+','+e.which); }); } }; });
/*directives*/ angular.module('activitiModeler').directive('ngKeydown',attrs) { //var functionToCall = scope.$eval(attrs.ngKeydown); elem.on('keyup',function(e){ alert(scope.employee.account); }); } }; });原文链接:https://www.f2er.com/angularjs/147544.html