-
-
Save talha08/dec4093e1353b492b4239bacdda80927 to your computer and use it in GitHub Desktop.
Angular $resource and transformResponse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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