Skip to content

Instantly share code, notes, and snippets.

@johnoscott
Created December 10, 2013 00:18
Show Gist options
  • Save johnoscott/7883626 to your computer and use it in GitHub Desktop.
Save johnoscott/7883626 to your computer and use it in GitHub Desktop.
AngularJS $resource usage
// Create $resource singleton service with custom methods
// SERVICE DebugOrder
.factory('Order', ['$resource', '$http',
function ($resource, $http) {
return $resource(Prefs.getResourceBaseUrl() + '/api/orders/:_id', {}, {
'count': {method: 'PUT', params: {_id: 'count'}},
'distinct': {method: 'PUT', params: {_id: 'distinct'}},
'find': {method: 'PUT', params: {_id: 'find'}, isArray: true},
'group': {method: 'PUT', params: {_id: 'group'}, isArray: true},
'mapReduce': {method: 'PUT', params: {_id: 'mapReduce'}, isArray: true},
'aggregate': {method: 'PUT', params: {_id: 'aggregate'}, isArray: true}
});
}
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment