Created
July 1, 2014 16:01
-
-
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
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
'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