我知道这个问题已经存在问题,但我无法在我的案例中找出解决方案。 我想在使用它之后重置$ scope值,但我无法在回调函数中访问i。
for (var i = 0; i < $scope.objects.length; i++) {
Priority.create({
"priority": $scope.selectedPriority[i].priority,
}, function (priority) {
$scope.selectedPriority[i].priority = undefined;
});
}
答案 0 :(得分:2)
function callbackFor(i, priority) {
$scope.selectedPriority[i].priority = undefined;
}
for (var i = 0; i < $scope.objects.length; i++) {
Priority.create({
"priority": $scope.selectedPriority[i].priority,
}, callbackFor(i, priority));
}