あなたが望むものを達成するための簡単な方法はありませんが、いくつかの選択肢があります。
JS:
var app = angular.module('myapp', []);
app.controller('MainCtrl', function($scope) {
$scope.items = [
{ name: 'foo', id: 1, eligible: true },
{ name: 'bar', id: 2, eligible: false },
{ name: 'test', id: 3, eligible: true }
];
$scope.onBlur = function($event, item){
// Here you find the target node in your 'items' array and update it with new value
_($scope.items).findWhere({id: item.id}).name = $event.currentTarget.value;
};
});
app.directive('ngBlur', function($parse) {
return function (scope, element, attr) {
var fn = $parse(attr.ngBlur);
element.bind('blur', function (event, arg) {
scope.$apply(function(){
fn(scope, {
$event : event,
arg: arg
});
});
});
};
});
はHTML:
<div ng-controller="MainCtrl">
<div ng-repeat="item in items | orderBy:'name'" >
<input value="{{item.name}}" ng-blur="onBlur($event, item)"/>
</div>
</div>
PlunkerをあなたはNG-モデルなしで動作し、代わりにblurイベントを使用する必要があります。
ただし、モデルとビューの間の双方向バインディングが壊れることに注意してください。
サーバーが自分のデータを送信するときに、ソートしたいフィールドがある追加の列 'sortBy'が含まれている場合、ng-repeatはorderByのためにそれを使用します。このフィールドは編集中ではないので、サーバーから行が戻ってくるまで変更されません。私。レコードを "保存"すると、$ scope内の同じ行を置き換えるsortByを含むデータベースから返されたデータがフェッチされ、編集が完了した後でのみページのソートが更新されます。 –