Angular:每次文本区域模型更新时,文本区域都会失去焦点
Angular: TextArea losing focus each times textarea model gets update
当 textarea 上的数据更新时,我正在使用 Socket.io
向所有订阅者广播更改,但我遇到的问题是,当数据更新并且 textarea
在 focus state
就全输了 focus
。我只想在 textarea
处于 blur state
时更新 textarea
而从不更新 focus state
.
我试过写这个但是它不起作用
<textarea ng-model-options="{ updateOn: 'blur'}" ng-model="value.note"></textarea>
找到替代解决方案
<textarea ng-blur="saveNote(value)" ng-model="value.note" ></textarea>
In controller
app.controller('testController', function($scope){
$scope.persistedValue = '';
$scope.saveNote = function(value){
var note = value.note;
if(note !== $scope.persistedValue){
//Only save if persistentValue is different from note value
}
}
});
当 textarea 上的数据更新时,我正在使用 Socket.io
向所有订阅者广播更改,但我遇到的问题是,当数据更新并且 textarea
在 focus state
就全输了 focus
。我只想在 textarea
处于 blur state
时更新 textarea
而从不更新 focus state
.
我试过写这个但是它不起作用
<textarea ng-model-options="{ updateOn: 'blur'}" ng-model="value.note"></textarea>
找到替代解决方案
<textarea ng-blur="saveNote(value)" ng-model="value.note" ></textarea>
In controller
app.controller('testController', function($scope){
$scope.persistedValue = '';
$scope.saveNote = function(value){
var note = value.note;
if(note !== $scope.persistedValue){
//Only save if persistentValue is different from note value
}
}
});