1
在我的服務我做HTTP GET請求,如下圖所示:無法顯示HTTP GET從工廠控制器響應在Angularjs應用
.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);
但我的總是顯示爲空。任何人都可以幫助我,爲什麼它會發生? 當我試圖顯示如下所示的時,它總是顯示空對象{}
。它應該顯示來自服務的響應json數組,但它顯示的是空對象。
<pre class="code"> {{resultList | json}}</pre>