Created
March 22, 2013 17:07
-
-
Save owenmead/5223009 to your computer and use it in GitHub Desktop.
Basic Angular service talking to a resource
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
angular.module('myApp') | |
.factory('people', function($resource, $q) { | |
var people_resource = $resource(myApp.API_BASE_URL + '/people/:personId'); | |
// Public API here | |
return { | |
getList: function() { | |
var deferred = $q.defer(); | |
var people = people_resource.query(function() { | |
angular.forEach(people, function(obj) { | |
obj.created = new Date(obj.created); | |
obj.modified = new Date(obj.modified); | |
}); | |
deferred.resolve(people); | |
}); | |
return deferred.promise; | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment