頭を悩ませましたが、ng-grid でセル データの変更を検出する方法がわかりません。次のスニペットは、save() を正しく呼び出す ng-change を使用していますが、キー付きエントリに対して呼び出されるため、必要なトリガーではありません。セルの編集がいつ完了するかを知る必要があります。
どんな助けでも大歓迎です。
angular.module('controllers', ['ngGrid']).
controller('ContactsListCtrl', ['$scope', 'Contacts', function ($scope, Contacts) {
var editableCellTemplate = '<input type="text" ng-class="\'colt\' + col.index" ng-input="COL_FIELD" ng-model="COL_FIELD" ng-change="save()"/>';
Contacts.get(function(data) {
$scope.contacts = data;
});
$scope.gridOptions = {
data: 'contacts',
enableCellSelection: true,
enableRowSelection: false,
enableCellEdit: true,
showSelectionCheckbox: true,
columnDefs: [
{field: 'lastName', displayName: 'Last Name', enableCellEdit: true, editableCellTemplate: editableCellTemplate},
{field: 'firstName', displayName: 'First Name', enableCellEdit: true, editableCellTemplate: editableCellTemplate},
{field: 'email', displayName: 'EMail Address', enableCellEdit: true, editableCellTemplate: editableCellTemplate},
{field: 'phone', displayName: 'Phone', enableCellEdit: true, editableCellTemplate: editableCellTemplate}
]
};
$scope.save = function() {
$scope.contact = this.row.entity;
Contacts.save($scope.contact);
}
}]);