我正在尝试弄清楚是否有办法向promise的回调函数传递索引参数。例如:
serviceCall.$promise.then(function(object){
$scope.object = object;
});
现在我想传递一个数组索引参数作为
serviceCall.$promise.then(function(object,i){
$scope.object[i] = something;
});
这能做到吗?请告诉我。
以下是代码:
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;
});
}
});
i
的值? - Yaron Schwimmer