aho*_*eth 7 blur keypress angularjs
我想在输入字段模糊时向服务器提交一些数据.用户还应该能够通过按Enter键来模糊输入字段.
不幸的是,这导致以下结果:$ rootScope:inprog:$ apply已在进行中错误.
普兰克 - 提前谢谢!
Lau*_*rin 10
这是发生了什么:
target.blur()模糊是同步执行的,并立即触发处理程序而不完成第一个摘要.
在我看来,这不是你的代码的问题,而是一个Angular错误.我一直在努力想出一个更好的解决方案,但我只能找到:
app.controller('BlurCtrl', function($scope, $timeout) {
$scope.blurModel = "I'm the value"
$scope.blurOnEnter = function( $event ) {
if ( $event.keyCode != 13 )
return
// this will finish the current digest before triggering the blur
$timeout(function () { $event.target.blur() }, 0, false);
}
$scope.onBlur = function() {
$scope.result = this.blurModel
}
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11739 次 |
| 最近记录: |