我需要在输入中捕获用户的退格。
所以我这样做了:
<input type="text" ui-keypress="{8:'removeTagOnBackspace()'}" ng-model="searchStudent" />
然后,在我的 Controller 中,我已经这样做了,只是为了检查它是否正常工作:
$scope.removeTagOnBackspace = function() {
console.log('here');
};
但不打印任何东西。
这有什么问题? angular 是否能够捕获退格?
最佳答案
知道了!
<input type="text" ng-keydown="removeTagOnBackspace($event)" />
和:
$scope.removeTagOnBackspace = function (event) {
if (event.keyCode === 8) {
console.log('here!');
}
};
关于AngularJS 退格键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26805717/