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屋!
查看全文