【发布时间】:2015-10-18 02:13:34
【问题描述】:
在我的服务中,我发出如下所示的 http get 请求:
.factory('InvoicesGeneralService', function ($http) {
return {
getAgreementsByCourierId: function (courierId) {
console.log("Courier in Services" + courierId);
return $http.get('/api/agreements/byCourierId', {params: {courierId: courierId}}).then(function (response) {
return response;
});
}
};
});
在浏览器控制台中,我看到以下响应:
[
{
"id":3,
"number":"AGR53786",
"ediNumber":"EDI7365",
"startDate":"2012-09-02",
"endDate":"2018-07-01",
"courier":{
"id":2,
"name":"FedEx",
"url":"www.fedex.com",
"isActive":true,
"isParcel":true
},
"client":{
"id":4,
"code":"KJGTR",
"name":"Hearty",
"isActive":true,
"engageDate":"2011-07-07",
"isSendRemittance":true,
"upsUserName":"Tkd",
"upsPassword":"kuu",
"isEligibleForTracking":true,
"isEligibleForAuditing":true,
"status":5
}
}
]
在我的控制器中,我将它分配给结果列表:
$scope.resultList = InvoicesGeneralService.getAgreementsByCourierId(selCourierId);
但我的resultList 总是显示为空。任何人都可以帮助我,为什么会这样?
当我尝试如下所示显示resultList 时,它总是显示空对象{}。它应该显示来自服务的响应 json 数组,但它显示的是空对象。
<pre class="code"> {{resultList | json}}</pre>
【问题讨论】:
标签: angularjs angularjs-scope angularjs-service