обновить директиву angularjs с 1.2 до 1.3. - PullRequest
2 голосов
/ 10 октября 2019

В данный момент пытаемся обновить версию с angularjs 1.2 до 1.3 и обнаружили проблему. Приложение имеет директиву подкачки:

app.directive("mobilePaginationList", function() {
 return {
        restrict: 'E',
        templateUrl: "Directives/mobilePagination/List/mobilePaginationList.html",
        transclude: true,
        replace: true,
        scope: {
            list: '=list'
        },
        link: function ($scope, $element, $attributes) {
            // code removed that is not relevant
            $scope.listToDisplay = PaginationService.from(origList).getPage(page);
        }
    }

}

шаблон:

<div class="row">
    <div class="col-xs-12">
        <div data-ng-repeat="currentItem in listToDisplay"  bindonce data-ng-transclude>
        </div>
        <mobile-pagination-pager data-ng-hide="vm.list.length <= 0"></mobile-pagination-pager>
    </div>
</div>

пример использования:

<mobile-pagination-list data-receipt-slider-menu-toggle="active" list="receipts" data-ng-hide="list.length <= 0 || rootVm.loading.receipts.value" class="row list-group">
        <a class="row list-group-item" data-bo-id="currentItem.attachNo" ui-sref="receiptWalletDetails({receiptId: currentItem.attachNo})">
            <div class="col-xs-11">
                <div class="row">
                    <div class="col-xs-8">
                        <h4 data-bo-bind="currentItem.description"></h4>
                    </div>
                    <div class="col-xs-4 text-right">
                        <h4 data-bo-bind="currentItem.amount | currency:''"></h4>
                    </div>
                </div>
                <div class="list-group-item-text">
                    <div class="row">
                        <div class="col-xs-8">
                            <span data-bo-bind="currentItem.notes"></span>
                        </div>
                        <div class="col-xs-4 text-right">
                            <span class="text-info"
                                data-bo-bind="currentItem.createDate | date: 'd MMM yyyy'">
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </a>
    </mobile-pagination-list>

То, что происходит, это то, что ng-repeatправильно отображает количество строк, но каждая строка не содержит данных из объекта currentItem. Строка содержит весь HTML-код, но в ней отсутствуют значения currentItem.

Я провел довольно много поисков этой проблемы, но пока не нашел решения.

Cheers

1 Ответ

1 голос
/ 10 октября 2019

Возможно, вы захотите включить $ parent до currentItem. Примерно так:

Использование:

<mobile-pagination-list data-receipt-slider-menu-toggle="active" list="receipts" data-ng-hide="list.length <= 0 || rootVm.loading.receipts.value" class="row list-group">

    <a class="row list-group-item" data-bo-id="$parent.currentItem.attachNo" ui-sref="receiptWalletDetails({receiptId: currentItem.attachNo})">
        <div class="col-xs-11">

          <h4 ng-bind="$parent.currentItem.description"></h4>
          <h4 ng-bind="$parent.currentItem.amount | currency:''"></h4>
          <span ng-bind="$parent.currentItem.notes"></span>
          <span class="text-info" ng-bind="$parent.currentItem.createDate | date: 'd MMM yyyy'">
          </span>

        </div>
    </a>
</mobile-pagination-list>

Вот поршень с рабочим примером.

Обратите внимание, чтоВаш код изменен, чтобы избавиться от зависимостей.

...