2016-09-26 30 views
-1

我在angualrjs中使用嵌套的ng-repeat並且內部的ng-repeat數組長度不同。所以索引不會按順序顯示。 我需要按順序輸出索引。我附上了輸出的截圖。

任何人都可以幫助我嗎?

<table class="table"> 
    <thead> 
      <th>#($index)</th> 
      <th>L #</th> 
      <th>C Name</th> 
      <th>A #</th> 
      <th>F P</th>       
    </thead> 
    <tbody ng-repeat="d in displayData" > 
     <tr ng-repeat="a in d.f_p track by $index" > 
      <td>{{($parent.$index*d.f_p.length)+($index+1)}}</td> 
      <td>{{d.lId}}</td> 
      <td>{{d.cName}}</td> 
      <td>{{$index+1}}</td> 
      <td>{{a}}</td>  
     </tr>  
</tbody> 
</table> 

$scope.displayData=[{"lId": "369857","cName": "ABCD","f_p":0.04401,0.04402,0.04403]},{"lId": "369858","cName": "BCDE",   "f_p":[0.04401,0.04402,0.04403,0.04404]},{"lId": "369859","cName": "CDEF",     "f_p":[0.04401,0.04402,0.04403,0.04404,0.04405]}]; 

enter image description here

+0

您可以創建的jsfiddle,因爲你的JSON對象似乎無效 –

+0

什麼是我們應該注意到截圖?問題不清楚,也不是你期望會有所不同 – charlietfl

回答

0

這是NG-INIT,唯一有效的情況下:

<tbody ng-repeat="d in displayData" ng-init="$outerIndex = $index">