Skip to content

Instantly share code, notes, and snippets.

@gabhi
Created May 13, 2014 19:43
Show Gist options
  • Save gabhi/b59aaf2da3a0ffa58b5b to your computer and use it in GitHub Desktop.
Save gabhi/b59aaf2da3a0ffa58b5b to your computer and use it in GitHub Desktop.
AngularJS: Creating multiple factories for every endpoint?
services.factory('Api', ['$resource',
function($resource) {
return {
Recipe: $resource('/recipes/:id', {id: '@id'}),
Users: $resource('/users/:id', {id: '@id'}),
Group: $resource('/groups/:id', {id: '@id'})
};
}]);
function myCtrl($scope, Api){
$scope.recipe = Api.Recipe.get({id: 1});
$scope.users = Api.Users.query();
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment