I am trying to figure out is there is any way to pass in an index argument to a promise's callback function. For instance.
serviceCall.$promise.then(function(object){
$scope.object = object;
});
Now I want to pass in an array index parameter as
serviceCall.$promise.then(function(object,i){
$scope.object[i] = something;
});
Can this be done? Please let me know.
Here is the code below
StudyService.studies.get({id:
$routeParams.studyIdentifier}).$promise.then(function(study) {
$scope.study = study;
for(var i=0;i<study.cases.length;i++){
StudyService.executionsteps.get({id:
$routeParams.studyIdentifier,caseId:study.cases[i].id})
.$promise.then(function(executionSteps,i){
$scope.study.cases[i].executionSteps = executionSteps;
});
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…