我的模块中有一个问题我正在从两个不同的ajax调用中映射两个响应(数组),因此我得到两个ajax调用的总响应作为单个数组。这里我必须使用该响应的总响应每个循环的角度以发布一些属性。但是由于每个循环,对象被重复发布。 这是我的代码:
$scope.fnGetDetails = function(uniqueId) {
$scope.uniqueId = uniqueId.jdDetails.uniqueId;
angular.forEach($scope.aIdResponse, function(value, key) {
console.log(value.jdDetails.uniqueId);
if (value.jdDetails.uniqueId == $scope.uniqueId) {
$scope.jdList = value.recruiter;
}
});
$scope.aRecPush = [];
$scope.aSelectedPush = [];
angular.forEach($scope.jdList, function(value, key) {
interviewStatusService.fnGetRecruiterDetails($scope.uniqueId, value).then(function(response) {
$scope.recResponse = response;
if ($scope.aRecPush.indexOf($scope.recResponse) === -1) {
$scope.aRecPush.push($scope.recResponse);
}
$scope.aRecVar = $scope.aRecPush;
});
interviewStatusService.fnGetSelectedProfiles($scope.uniqueId, value).then(function(response) {
$scope.aRes = response;
$scope.aLength = $scope.aRes.length;
if ($scope.aSelectedPush.indexOf($scope.aLength) === -1) {
$scope.aSelectedPush.push($scope.aLength);
$scope.aSelectedVar = $scope.aSelectedPush;
$scope.mappedData = $scope.aRecVar.map(function(value, index) {
return {
data: value,
value: $scope.aSelectedVar[index]
}
});
}
angular.forEach($scope.mappedData, function(value, key) {
interviewStatusService.fnPostRecruiterTrack(value.data[0].recruiter, value.data[0].length, value.data[0].uniqueId, value.value).then(function(response) {
console.log(response);
})
});
});
});
任何帮助都将不胜感激。