Skip to content

Instantly share code, notes, and snippets.

@yelvert
Created September 2, 2014 07:14
Show Gist options
  • Save yelvert/36747991a623268b9b03 to your computer and use it in GitHub Desktop.
Save yelvert/36747991a623268b9b03 to your computer and use it in GitHub Desktop.
Angular Resource factory with an API
(function() {
'use strict';
angular.module('someModule').factory('SomeResource', [
'$http',
function ($http) {
$http.get('http://example.com/some_resources').then(function (res) {
var resources = res.data;
return resourceFactory = {
all: function (){
return resources;
},
find: function (id) {
return _.where(resources, {id: id});
}
};
});
}
]);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment