angularJS文本框根据输入字符(文本框值)进行查询ng-keydown ng-keyup

前端之家收集整理的这篇文章主要介绍了angularJS文本框根据输入字符(文本框值)进行查询ng-keydown ng-keyup前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
html:

<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

猜你在找的Angularjs相关文章