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', function() {
    return {
        restrict: 'A',
        link: function(scope, elem, attrs) {
             	  //var functionToCall = scope.$eval(attrs.ngKeydown);
             elem.on('keyup', function(e){
            	 alert(scope.employee.account);
             });
        }
    };
});

猜你喜欢

转载自franciswmf.iteye.com/blog/2288654