ng-repeat内的角度自定义指令不在第二次加载时执行

时间:2017-11-23 20:08:28

标签: angularjs angularjs-directive angular-ui-router angularjs-scope

(function() {
  'use strict';
  angular.module('app.core').directive('abrRecText', abrRecText);

  function abrRecText() {
    return {
      restrict: 'E',
      scope: {
        details: '='
      },
      controller: recTextController,
      controllerAs: 'vm',
      templateUrl: 'app/abr/abr-directives/abr-templates/abr-rec-text.html'
    };
  }
})();

上面的代码是自定义指令和下面的视图部分 在里面,我在第二次加载时得到了事件,但指令没有得到

                                                                                                                     

点击页码,调用api并获得回复。

        <div class="abr-pagination">
            <div class="abr-pagination-wrap">
                <div class="abr-pagination-split  pull-left">
                    <paging class="small" page="vm.filterData.paging.currentPageNumber" page-size="vm.filterData.paging.pageSize" total="total" ul-class="pagination rmapp" active-class="active" disabled-class="disabled" adjacent="1" app-name="rm" dots="..." show-prev-next="true" show-first-last="true" hide-if-empty="true" paging-action="vm.pageChanged(page)">
                    </paging>
                </div>
            </div>
            <div class="col-md-12 nopadding table-show-page pagination">
                <div class="col-md-2 nopadding abr-pagination-goto goto-page table-go-to pull-left">
                    <lable> Go to </lable>
                    <input type="number" aria-invalid="false" ng-model="vm.filterData.paging.currentPageNumber" ng-change="vm.getTableData()" />
                </div>
                <div class="col-md-4 nopadding abr-pagination-perpage pagination-per-page table-entries pull-left">
                    <lable class="pull-left">Entries per page </lable>
                    <div class="pull-left pagination-select-container">
                        <select ng-model="vm.filterData.paging.pageSize" ng-options="item for item in vm.selectitems" ng-change="vm.getTableData()"></select>
                    </div>
                </div>

                </div>
            </div>
        </div>




        <ul>
                <li class="inlineblock" ng-repeat="(key,event) in events.recommendationObj track by $index">
                    <div class="col-md-12 paddingfive">
                        <abr-rec-text details="[{'cogKey': 'rectext','cogValue': event.recommendedText },{'cogKey': 'startsAt','cogValue': event.startsAt  }, {'cogKey': 'isStory','cogValue':false },{'cogKey': 'widgetMasterId','cogValue':events.widgetMasterId },{'cogKey': 'cardIcId','cogValue':event.cardIcId},{'cogKey': 'attrId','cogValue':attrId},{'cogKey': 'widgetId','cogValue':widgetId}]"></abr-rec-text>
                    </div>
                </li>
            </ul>
            <div class="abr-pagination">
                <div class="abr-pagination-wrap">
                    <div class="abr-pagination-split  pull-left">
                        <paging class="small" page="vm.filterData.paging.currentPageNumber" page-size="vm.filterData.paging.pageSize" total="total" ul-class="pagination rmapp" active-class="active" disabled-class="disabled" adjacent="1" app-name="rm" dots="..." show-prev-next="true" show-first-last="true" hide-if-empty="true" paging-action="vm.pageChanged(page)">
                        </paging>
                    </div>
                </div>
                <div class="col-md-12 nopadding table-show-page pagination">
                    <div class="col-md-2 nopadding abr-pagination-goto goto-page table-go-to pull-left">
                        <lable> Go to </lable>
                        <input type="number" aria-invalid="false" ng-model="vm.filterData.paging.currentPageNumber" ng-change="vm.getTableData()" />
                    </div>
                    <div class="col-md-4 nopadding abr-pagination-perpage pagination-per-page table-entries pull-left">
                        <lable class="pull-left">Entries per page </lable>
                        <div class="pull-left pagination-select-container">
                            <select ng-model="vm.filterData.paging.pageSize" ng-options="item for item in vm.selectitems" ng-change="vm.getTableData()"></select>
                        </div>
                    </div>
                    </div>
                </div>
            </div>

最初指令正在加载,一旦我点击第二页的分页按钮控制器执行并获得响应,但该指令未根据第二个响应执行。

任何想法将不胜感激!

0 个答案:

没有答案