AngularJS退格按键 [英] AngularJS backspace keypress
本文介绍了AngularJS退格按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在输入中捕获用户的退格键.
I need to capture user's backspaces inside an input.
所以我做到了:
<input type="text" ui-keypress="{8:'removeTagOnBackspace()'}" ng-model="searchStudent" />
然后,在我的控制器内部完成此操作,只是为了检查其是否正常工作:
And then, inside my controller I've done this, just to check if it's working:
$scope.removeTagOnBackspace = function() {
console.log('here');
};
但不打印任何内容. 这有什么问题? angular能够捕获退格键吗?
But is not printing anything. What is wrong with this? Is angular able to capture backspaces?
推荐答案
知道了!
<input type="text" ng-keydown="removeTagOnBackspace($event)" />
并且:
$scope.removeTagOnBackspace = function (event) {
if (event.keyCode === 8) {
console.log('here!');
}
};
这篇关于AngularJS退格按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文