2015-07-12 37 views
0

我正在使用Socket.io brodcasting更改爲所有它的訂戶時,textarea上的數據更新但我遇到的問題是,當數據得到更新和textarea是在focus state它全部丟失focus。我只想更新textarea,僅當它在blur state中時,並且從不在focus state上。Angular:TextArea每次失去焦點textarea模型獲取更新

我試着寫這一點,但它亙古不變的作品

<textarea ng-model-options="{ updateOn: 'blur'}" ng-model="value.note"></textarea> 

回答

0

找到一個替代的解決方案

<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 


     } 
    } 
});