Skip to content

Instantly share code, notes, and snippets.

@cpoDesign
Created July 1, 2014 16:01
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 cpoDesign/b79553a4454e98586bd4 to your computer and use it in GitHub Desktop.
Save cpoDesign/b79553a4454e98586bd4 to your computer and use it in GitHub Desktop.
Using angular to define multiple actions with specific actions defined in one place. This allows to have multiple actions defined in controller and still have only one url configuration
'use strict';
app.service('teamManagementSvc', function ($resource) {
var resource = $resource('/api/:action',
{ /*defaults*/ },
{
/* Action definitions */
updateTeamName: { method: 'POST', params: { action: 'Update' }, isArray: false },
getLatest: { method: 'GET', params: { action: 'LatestForTeam' }, isArray: false }
});
return {
getLatest: function (categoryId) {
return resource.getLatest({categoryId: categoryId});
},
update: function (teamId, name) {
return resource.updateTeamName({
TeamId: teamId,
TeamName: name
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment