Javascript 角度:每次TextArea模型更新时,TextArea都会失去焦点
我正在使用Javascript 角度:每次TextArea模型更新时,TextArea都会失去焦点,javascript,jquery,angularjs,socket.io,Javascript,Jquery,Angularjs,Socket.io,我正在使用Socket.io在textarea上的数据更新时向所有it订户广播更改,但我遇到的问题是,当数据更新且textarea处于focus状态时,它会丢失所有focus。我只想更新文本区域仅当它处于模糊状态且从不处于焦点状态时 我试着写这篇文章,但没用 <textarea ng-model-options="{ updateOn: 'blur'}" ng-model="value.note"></textarea> 找到了替代解决方案 <textarea
Socket.io
在textarea上的数据更新时向所有it订户广播更改,但我遇到的问题是,当数据更新且textarea
处于focus状态时,它会丢失所有focus
。我只想更新文本区域
仅当它处于模糊状态
且从不处于焦点状态
时
我试着写这篇文章,但没用
<textarea ng-model-options="{ updateOn: 'blur'}" ng-model="value.note"></textarea>
找到了替代解决方案
<textarea ng-blur="saveNote(value)" ng-model="value.note" ></textarea>
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
}
}
});