Skip to content

Instantly share code, notes, and snippets.

@karlkori
Forked from vladikoff/resource.js
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save karlkori/eea2fdd8aa8b6c3c98fe to your computer and use it in GitHub Desktop.

Select an option

Save karlkori/eea2fdd8aa8b6c3c98fe to your computer and use it in GitHub Desktop.
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