Skip to content

Instantly share code, notes, and snippets.

@solocommand
Created March 28, 2013 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solocommand/5265691 to your computer and use it in GitHub Desktop.
Save solocommand/5265691 to your computer and use it in GitHub Desktop.
Angular service
angular.module('modelService', ['ngResource']).factory('ModelService', function ($resource) {
return $resource(
'/supermodlr/api/:model_name/:action/:pk_id',
{ model_name:'@model_name', action : '@action', pk_id: '@pk_id' },
{
'create': { method: 'POST', params: { action: 'create' } },
'read' : { method: 'GET', params: { action: 'read' }, isArray: false },
'update': { method: 'POST', params: { action: 'update' } },
'delete': { method: 'POST', params: { action: 'delete' } },
'query' : { method: 'GET', params: { action: 'query', q: '@query' }, isArray: true }
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment