Skip to content

Instantly share code, notes, and snippets.

@vladikoff
Created April 17, 2014 17:52
Show Gist options
  • Save vladikoff/11001070 to your computer and use it in GitHub Desktop.
Save vladikoff/11001070 to your computer and use it in GitHub Desktop.
Angular $resource and transformResponse
angular.module('itemServices', ['ngResource'])
.factory('Item', ['$resource',
function ($resource) {
return $resource('items/:id',
{id: '@id'},
{
query: {
isArray: true,
method: 'GET',
params: {},
transformResponse: function (data) {
return angular.fromJson(data).body.rows
}
},
get: {method: 'GET', params: {id: '@id'}},
save: {method: 'POST'},
update: {method: 'PUT', params: {id: '@id'}},
delete: { method: 'DELETE', params: {} }
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment