Created
January 8, 2013 20:14
-
-
Save jeffgabhart/4487508 to your computer and use it in GitHub Desktop.
AngularJS Services Pattern
This file contains hidden or 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
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