0
완료 시간 :내가 두 배열이
for (var i = 0, len = $scope.grid.data.length; i < len; i++) {
if (!angular.equals($scope.grid.data[i], $scope.grid.backup[i])) {
var rowData = $scope.grid.data[i]
var idColumn = $scope.entityType.toLowerCase() + 'Id';
var entityId = rowData[idColumn];
entityService.putEntity($scope.entityType, entityId, $scope.grid.data[i])
.then(function (result) {
angular.copy(result, $scope.grid.data[i]);
angular.copy(result, $scope.grid.backup[i]);
}, function (result) {
alert("Error: " + result);
})
}
}
하고 데이터베이스 업데이트하려면 다음
이putEntity: function (entityType, entityId, entity) {
var deferred = $q.defer();
EntityResource.putEntity({ entityType: entityType, entityId: entityId }, entity,
function (resp) {
deferred.resolve(resp);
}, function (resp) {
deferred.reject('Error updating');
});
return deferred.promise;
}
이 스크립트는 제대로 장을주의 사항 es를 실행하고 데이터베이스를 업데이트합니다. putEntity이 결과로 반환하고 그 다음 $의 scope.grid.data [I]와 $ scope.grid.backup [i]를
이을에 결과를 복사 할 때
그러나 문제가있는 것입니다 나중에 발생하고이 작업을 시도 할 때 항상 요소 11에 넣으려고합니다.
putEntity에서 반환 된 데이터가 grid.data의 올바른 요소로 다시 복사되도록 보장 할 수있는 아이디어가 누구에게 있습니까? grid.backup 배열?