how to keep a reference to arguments passed in http call in angularJs

Hi i need to save a reference to an argument passed in a $http call so i can that way i can use with the corresponding response result in a subsequent $http call in promise chain .

var IncidentsPromises = [];
  for (var i = 0; i < $scope.mySelections.length; i++) {
    service_id = $scope.mySelections[i].services[0].service_object_id;
    var promis =service.createTicket($scope.mySelections[i],additional_info, incidentTicketParent)
    IncidentsPromises .push(promis)
  }
$q.all(IncidentsPromises)
  .then(function (res) {
// I need to match the number of the ticket returned 
//by the createticket() call to the serviceId that created it.
//before i can make the acknowledge call i need the service id matching the incident Id
//since the call is async i can't rely on the order of the response.

  service.acknowledge(service_id, incidentId)
    .then(function (res) {
       console.log("Incident acknowledged ")
    }, function (err) {

      $log.log("Incidents not Acknowledge");
    });
  }, function (err) {
      $log.log("tickets not created");
    });

the createTicket and acknowledge are just simple $http calls that return a promise.

Any sugestion is more than welcome . thanks in advance


Source: stackoverflow-javascript