为什么Javascript内部承诺无法正确加载数据?

时间:2018-12-17 13:29:33

标签: javascript angularjs ajax rest request

我必须使用Javascript Promise从后端读取一些信息,这是代码:

.then( function () {
                        for (var result in $scope.registrationsToAcceptAgreement) {

                                eventsServices.getGroupParticipants( 
                                    $scope.registrationsToAcceptAgreement[result].userRegistrations[0].groupName, 
                                    $scope.registrationsToAcceptAgreement[result].userRegistrations[0].eventId 
                                )

                .then( function (participantsResults) {
                                    $scope.registrationsToAcceptAgreement[result].userRegistrations[0].participantsList = participantsResults;
                                });

                            }


                        }

                    })

假设应该为“ registrationsToAcceptAgreement [结果]”中的每个项目填写参与者列表,但仅填写最后一个元素。

为什么?

0 个答案:

没有答案