Javascript 如何在angularjs ng repeat中更改当前选择时为选择提供新选项

Javascript 如何在angularjs ng repeat中更改当前选择时为选择提供新选项,javascript,angularjs,Javascript,Angularjs,“任何机构都可以让我知道在ng repeat中更改选择框时调用函数,该函数将返回第一个选择框下方第二个选择框可用的数据,但不是所有选择框的数据” 假设我有两个产品 product 1 select1-on change of this select2-this should change product2 select1-on change of this select2-this should change 但现在发生的是 product 1 select1-on cha

“任何机构都可以让我知道在ng repeat中更改选择框时调用函数,该函数将返回第一个选择框下方第二个选择框可用的数据,但不是所有选择框的数据” 假设我有两个产品

product 1  
select1-on change of this
select2-this should change

product2
select1-on change of this
select2-this should change
但现在发生的是

 product 1  
    select1-on change of this
    select2-is changing

    product2
    select1-
    select2-this is also changing
有人能帮我吗

我有一个ng repeat循环,其中我有两个选择框,对于第一个选择框,我从api调用中获取数据,当用户更改第一个选择框中的任何选项时,我必须获取代码并与其代码匹配整个数据,并向第二个选择框提供选项

但主要问题是,我在ng侧循环的整个过程重复,因此,如果从第一个产品中选择第一个选择框时有2个或更多产品,则会更改所有产品的所有第二个选择框数据

这是我的密码

<div class="" ng-repeat="product in products ">
    <div ng-show="IsVisible" class="form-group row sub-div vsub-div-fw">
                                            <div class="col-sm-6 fd">
                                                <p class="cust-label" for="pay_opt">Select a plan.</p>
                                                <select ng-change="getPaymentOptions(orders.selectedSub[$index],index)" ng-init="orders.selectedSub[$index] = product.recurrence[0].code"  ng-model="orders.selectedSub[$index]" ng-options="sub.code as sub.name for sub in product.recurrence "  class="input-lg form-control select-community-list" id="pay_opt">
                                                <!-- <option value="">Select Subscription Plan</option> -->
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group row sub-div vsub-div-fw">
                                             <div class="col-sm-6 fd">
                                                <p class="cust-label" for="">Select a payment option.</p>
                                                <select  required="required" ng-model="orders.selectedPayment[$index]" class="input-lg selectPaymentOption paymentOption{{$index}} form-control"  id="" >
                                                <option ng-init="orders.selectedPayment[$index] = product.payment_options[0]" ng-repeat="opt in product.payment_options" value="{{opt}}"  class="myPaymentBox">{{opt.split("_").join(" ") }}</option> 
                                                </select>
                                                <p id="paymentOptionErr{{$index}}" class="alert alert-danger product-error-msg"><i class="fa fa-exclamation-triangle"></i> Please select payment option to proceed.</p>
                                            </div>
</div>

当我们更改第一个选择框时,将调用上述函数,以获取第二个选择框的选项。但当我们有更多产品时,更改产品一的第一个选择框将更改所有第二个选择框选项。如何在更改函数时使其唯一?

您能用代码设置jsfidle示例吗?抱歉,代码太大了,您能告诉我如何处理select更改时的函数调用,但在ng repeat中?您能用代码设置jsfidle示例吗?抱歉,代码太大了,您能让我知道如何处理select更改时的函数调用,但在ng repeat中?
$scope.getPaymentOptions=function(plan,i){
                angular.forEach($scope.products,function(p){
                    angular.forEach(p.recurrence,function(r){
                        if (r.code==plan) {
                            p.payment_options=r.payment_type;
                            $scope.orders.selectedPayment[i] = r.payment_type[0];
                        };
                    });
                })
            }