2016-06-10 38 views
1

HTML沒有得到可變角引導分頁 - 在 '範圍'

<table ng-show="ecu.dtcs"> 
    <tbody> 
     <tr> 
      <td colspan="4"> 
       <uib-accordion close-others="true"> 
        <uib-accordion-group ng-repeat="dtc in dtcList track by $index"> 
         ... 
        </uib-accordion-group> 
       </uib-accordion> 
      </td> 
     </tr> 
    </tbody> 
</table> 

<uib-pagination 
    total-items="{{ totalItems }}" 
    ng-model="{{ currentPage }}" 
    items-per-page="{{ itemsPerPage }}" 
    boundary-link-numbers="true" 
    ng-change="setPagingData(currentPage)"> 
</uib-pagination> 

JS(指令)

link: function (scope) { 

    scope.showEcuDetails = function (ecu) { 

     // For pagination 
     scope.itemsPerPage = 20; 
     scope.totalItems = ecu.dtcs.length; 
     scope.currentPage = 1; 

     scope.setPagingData = function(currentPage) { 
      var start = (currentPage - 1) * scope.itemsPerPage, 
       end = currentPage * scope.itemsPerPage; 

      scope.dtcList = ecu.dtcs.slice(start, end); 
     }; 

     scope.setPagingData(scope.currentPage); 
    }; 
} 
  • ecu.dtcs:保存所有的數據,我想要
  • dtcList:盛放sliced列表中的每個20個元素

我已經使用了Angular-Bootstrap文檔和也引用本source(除了已經使用ng-change改變的範圍的列表,而不是一個$watch

我有徹底調試應用程序,我可以看到dtcList正在成爲填充前20個元素。然而,進入HTML,沒有什麼顯示

我也試着寫.filter(如顯示here),但因爲變量設置在指令的範圍內而不是控制器,我的過濾器,不能看到變量

注:對於分頁設置,引用變量的作用域(即totalItems),我用角這樣的表達式顯示在這個問題上,也基本字符串,如文檔中(即"totalItems"

我認爲概念和t他這樣,我有它的那一刻書面應該工作,它只是HTML無法看到dtcList出於某種原因

編輯

它可能有助於知道,這是一個角度的UI自舉模式。下面的函數調用setPagingData(),我有這樣的:

$uibModal.open({ 
    templateUrl: "ecuDialog.html", 
    size: "lg", 
    windowClass: "modalDialogs networkTest__largeContentDialog", 
    scope: scope 
}); 

templateUrl是其中的我已經寫在這個問題的HTML部分。這讓我想起這是否是這個問題,但我的同事們向我保證,它不會以任何方式影響結果。

EDIT 2

不幸的是,我們的同事的1誰在AngularJS已經觀看了代碼與文檔一起並不能看到其中的任何錯誤。它可能是一個角度錯誤,或者是它不喜歡的angular-ui-bootstrap多個元素的組合嗎?

事情我結合是:

  • ui-modal
  • ui-accordion
  • ui-pagination
+0

請你給我們提供一個fillde? –

+0

不幸的是,我不能應用程序太密集,從其他地方拉數據/元素,他們太重,不能嘲笑。我會更新我的問題,通過提供更多的細節 – wmash

+0

這將是偉大的。 –

回答

0

解決方案:

我的代碼是正確的。我的同事進行了一次嘗試,並將我寫入另一個指令的代碼。我們都不確定爲什麼會出現這種情況,也許Angular不喜歡過度擁擠的指令?