Showing grid is working perfect:
FACTORY (excerpt) works perfect
.factory('MyResource', function($resource) {
return $resource(
'http://my-rest-api/whatever/:id',
{
id: '@_id'
},
{
update: {
method: 'PUT'
}
}
)})
CONTROLLER (excerpt1) works perfekt
$scope.myGrid.gridConfiguration = {..}
$scope.myGrid.columnDefs = {..}
$scope.myGrid.data = MyResource.query();
VIEW (excerpt) works perfect
<div
ui-grid="myGrid"
ui-grid-edit
ui-grid-cellNav
class="gridMid">
</div>
CONTROLLER (excerpt2) But Update does not Work:
$scope.myGrid.gridConfiguration.onRegisterApi = function(gridApi){
//set gridApi on scope
$scope.gridApi = gridApi;
gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){
// Following works
$scope.msg.lastCellEdited = 'Edited (#' + rowEntity.id + '), Column: (' + colDef.name + ') New Value: (' + newValue + ') Old Value: (' + oldValue +")" ;
**// THIS DOES NOT WORK**
MyResource.update({id: rowEntity.id },rowEntity);
// following works too
$scope.$apply();
});
};
Where is my mistake?
There were no mistakes, the REST-SERVER was not working properly.
For all, who want to test a DUMMY-REST-API with Angular UI-Grid and ngResource, I've prepared a repository here:
https://github.com/webia1/ANGULAR_SKELETON_VERTICAL_TABS
It uses HTTP-PUT to update a ressource.