您的位置:首页 > Web前端 > AngularJS

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

2017-04-12 16:37 369 查看
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);
});
}
};
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐