Skip to content

Instantly share code, notes, and snippets.

@jeffgabhart
Created January 8, 2013 20:14
Show Gist options
  • Save jeffgabhart/4487508 to your computer and use it in GitHub Desktop.
Save jeffgabhart/4487508 to your computer and use it in GitHub Desktop.
AngularJS Services Pattern
var services = angular.module('services', []);
services.factory('catalog' ['$http', function($http) {
var catalog = {};
catalog.init = function() {
return $http.get('/api/catalog').then(function (response) {
angular.extend(catalog, response.data);
});
};
return catalog;
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment