2016-12-09 11 views
5

Czy jest możliwe powtórzenie kątowe, aby to osiągnąć? Zasadniczo zastanawiam się, czy istnieje sposób na zapętlenie 2 razem? Naprawdę doceniam każdą pomoc!Jak ustawić dwie kolumny do powtórzenia dla jednej pozycji na liście?

Kontroler:

$scope.date=[ 
    {ID:1,Date:'2016-11-12'}, 
    {ID:2,Date:'2016-11-15'}, 
    {ID:3,Date:'2016-12-06'} 
] 

HTML:

<table border="1" align="center"> 
    <tr>    
     <th rowspan="2">ITEMCODE</th> 
     <th rowspan="2">DEBTORCODE</th> 
     <th colspan="2" ng-repeat="d in date">{{d.Date}}</th> 
    </tr>  
    <tr> 
     <th>Bal</th> 
     <th>Order</th> 
    </tr> 
</table> 

I życzę kolumnę Bal i porządek będą powtarzać obok siebie pod każdym kolumny dat. And I expect the column Bal and Order will repeat side by side

Odpowiedz

7

Można użyć ng-repeat-start i ng-repeat-end, który został wprowadzony w kątowa 1,2

<th ng-repeat-start="d in date">Bal</th> 
<th ng-repeat-end>Order</th> 

Przykład https://jsfiddle.net/9ve3fu0m/

+0

OMG! To działa jak urok!!! Dziękuje bardzo!!! –

1

Można tego dokonać za pomocą tabeli zagnieżdżonej tak:

<table border="1" align="center"> 
<tr> 
    <th rowspan="2">ITEMCODE</th> 
    <th rowspan="2">DEBTORCODE</th> 
    <th colspan="2" ng-repeat="d in date"> 
    <table border="1" > 
     <tr> 
     <th colspan="2">{{d.Date}}</th> 
     </tr> 
     <tr> 
     <th>Bal</th> 
     <th>Order</th> 
     </tr> 
    </table> 
    </th> 
</tr> 
</table> 
+0

Thx to działa !!! ale trzeba dostosować css, aby było idealne! –

0

można użyć nG-repeat-start i praca nG-repeat-end

<table border="1" align="center"> 
<tr>    
    <th rowspan="2">ITEMCODE</th> 
    <th rowspan="2">DEBTORCODE</th> 
    <th colspan="2" ng-repeat="d in date">{{d.Date}}</th> 
</tr>  
<tr> 
    <th ng-repeat-start="d in date">Bal</th> 
    <th ng-repeat-end>Order</th> 
</tr> 

Powiązane problemy