Created
May 13, 2014 19:43
-
-
Save gabhi/b59aaf2da3a0ffa58b5b to your computer and use it in GitHub Desktop.
AngularJS: Creating multiple factories for every endpoint?
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
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