爲了在工廠調用中設置我的url的基礎,我需要調用另一個工廠的方法來獲取配置。下面不斷拋出一個Provider 'reportService' must return a value from $get factory method.
錯誤:將工廠注入另一個Angular工廠
.factory('reportService', ['$resource', 'serverService',
function($resource, serverService) {
serverService.getConfiguration().$promise.then(function(config) {
var base = config.reporting.url;
return $resource(base, {}, {
getReportResults: {method: 'POST', url: base + '/api/reports/:id/versions/:version'}
});
});
}])
Server服務:
angular.module('app')
.factory('serverService', ['$resource',
function($resource) {
var base = '/api/server/';
return $resource(base, {}, {
getConfiguration: {method: 'GET', url: base + 'configuration'}
});
}]);
我們可以看到serverService的代碼嗎? – jbrown