嵌套的 ng-repeat 具有关于重复数据的开放特定索引

nested ng-repeat with open particular index with respect to repeated data

每次点击开关时,所有付款都会被新付款取代。我的问题是如何维护每次点击特定索引的付款并在相应索引处显示。请帮帮我

here is my html

            <tbody data-ng-repeat="invoice in relatedInvoices>
                <tr>
                    <td class="td-bottom-border">
                            {{invoice.PayableCurrencyCode}} {{invoice.PayablePaidAmount | number: 2}}<br />
                            <small>
                                <a data-ng-click="isOpenPayablePayments[$index] = !isOpenPayablePayments[$index]; togglePayablePayments(invoice.PayableInvoiceId)">Paid</a>
                            </small>
                    </td>
                </tr>
                <tr data-ng-show="isOpenPayablePayments[$index]">
                    <td>
                        <table>
                            <thead>
                                <tr>
                                    <th>Transaction Id</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr data-ng-repeat="payment in payablePayments">
                                    <td>{{payment.TransactionId}}</td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>

Here is my javascript

    var getPayments = function (invoiceId) {
        paymentService.getPayments(invoiceId).then(function (paymentsResponse) {
            return paymentsResponse.data;
        });
    };

    $scope.togglePayablePayments = function(invoiceId) {
        $scope.payablePayments = getPayments(invoiceId);
    };

如果我没理解错的话,你希望每张发票都有 "payablePayments"。

这是有效的:http://plnkr.co/edit/cj3jxZ?p=info

试试

// init at beginning
$scope.payablePayments = [];

$scope.togglePayablePayments = function(invoiceId) {
    $scope.payablePayments[invoiceId] = getPayments(invoiceId);
}; 

然后

<tr data-ng-repeat="payment in payablePayments[invoice.PayableInvoiceId]">

否则您将覆盖前面发票的对象。