나는 며칠 동안 이것을 뒤집어 썼고, 내가 뭘 잘못하고 있는지 파악할 수 없기 때문에 어떤 생각이나 어둠 속에서도 촬영할 수 있습니다. AngularJS $ http get 메서드를 사용하여 사용자에게 나머지 서비스의 응답을 표시하려고하는데, 데이터 객체를 콘솔에 인쇄하면 숫자 200이 일관되게 나타납니다 (나는 꽤 확신하고 있습니다). 내 상태 코드). 매번 성공을 거두고 요청을 보내면 Chrome 디버그 도구가 내게 올바른 모든 데이터가 포함 된 응답을 표시합니다. 변수를 표시 할 수없는 것 같습니다. 네가 무엇이든 생각하면 나 한테 알려줘! 감사!
내 자바 스크립트 :
$scope.resendDestinations = [];
$scope.resendDestGet = function() {
var omtTypeCodeString = '';
for(var i = 0; i < $scope.mySelections.length; i++){
if(omtTypeCodeString == ''){
omtTypeCodeString = $scope.mySelections[i].orderHeader.omtOrderTypeCode;
}
else{
omtTypeCodeString = omtTypeCodeString + ',' + $scope.mySelections[i].orderHeader.omtOrderTypeCode;
}
}
$http({
method: 'GET',
url: restService.pom + //service url,
respondType: 'json',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Access-Control-Allow-Credentials': true
},
params: {
orderTypeCode: omtTypeCodeString,
transactionCode: 3
}
}).success(function (status, data, response, header) {
console.log("Success!");
//TODO see if this is being used... has to be
status = parseInt(status);
$scope.resendDestinations = data.multipleOrders;
if (status == 200 && $scope.resendDestinations.length == 0) {
$scope.bigAlert.title = 'Error',
$scope.bigAlert.header = 'Search Error';
$scope.bigAlert.content = 'Current search parameters do not match any results.';
$scope.showBigAlert();
}
else{
$scope.resendDestinations = data;
console.log("Data DestinationList here: ");
console.log($scope.resendDestinations);
console.log(data.multipleOrders);
console.log(data);
}
$scope.isSearching = false;
}).error(function (response, data, status, header) {
//Do error things
});
return $scope.resendDestinations;
};
그리고 서비스 응답 :
[{"destCode":3,"destDescr":"Repository","attributes":null},{"destCode":4,"destDescr":"Pipeline","attributes":null},{"destCode":1,"destDescr":"Processor","attributes":null},{"destCode":2,"destDescr":"DEW","attributes":null}, {"destCode":7,"destDescr":"Management System","attributes":null}, {"destCode":8,"destDescr":"Source","attributes":null}]
기능 헤더의 상태 및 데이터 순서를 변경하십시오. – Beterraba