Created
September 2, 2014 07:14
-
-
Save yelvert/36747991a623268b9b03 to your computer and use it in GitHub Desktop.
Angular Resource factory with an API
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
(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