Mat*_*ima 10 keypress angularjs angular-ui
我需要在输入中捕获用户的退格.
所以我做到了这一点:
<input type="text" ui-keypress="{8:'removeTagOnBackspace()'}" ng-model="searchStudent" />
Run Code Online (Sandbox Code Playgroud)
然后,在我的控制器里面我做了这个,只是为了检查它是否正常工作:
$scope.removeTagOnBackspace = function() {
console.log('here');
};
Run Code Online (Sandbox Code Playgroud)
但是不打印任何东西.这有什么问题?角度是否能够捕获退格?
Mat*_*ima 35
得到它了!
<input type="text" ng-keydown="removeTagOnBackspace($event)" />
Run Code Online (Sandbox Code Playgroud)
和:
$scope.removeTagOnBackspace = function (event) {
if (event.keyCode === 8) {
console.log('here!');
}
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21388 次 |
| 最近记录: |