AngularJS Best Practice - Factory with multiple methods
问题 I have a factory that serves up three different $http.get methods. angular.module('myApp') .factory('getFactory', function ($http, $q) { return { methodOne: function () { var deferred = $q.defer(); $http.get('path/to/data') .then(function successCallback (data) { deferred.resolve(data); },function errorCallback (response) { console.log(response); }); return deferred.promise; }, methodTwo: function (arg1, arg2) { var deferred = $q.defer(); $http.get('path/to/' + arg1 + '/some/' + arg2 + 'more