2013-11-23 13 views
23

次の表の行が一般的です。AngularJSで2行ずつ繰り返す方法

<tr ng-repeat="item in items"> 
    <td>{{item.id}}</td> 
    <td>{{item.subject}}</td> 
    <td>{{item.author}}</td> 
    <td>{{item.date}}</td> 
</tr> 

ただし、2行ずつ繰り返す方法はありますか?

<tr ??> 
    <td rowspan=2>{{item.id}}</td> 
    <td colspan=2>{{item.subject}}</td> 
</tr> 
<tr ??> 
    <td>{{item.author}}</td> 
    <td>{{item.date}}</td> 
</tr> 
+2

[Angular.js ng-repeat between multiple trs]の複製が可能です(http://stackoverflow.com/questions/12979205/angular-js-ng-repeat-across-multiple-trs) – Amicable

答えて

44

あなたはAngularJS 1.2+を使用している場合は、ng-repeat-startng-repeat-endを使用することができます。

<tr ng-repeat-start="item in items"> 
    <td rowspan=2>{{item.id}}</td> 
    <td colspan=2>{{item.subject}}</td> 
</tr> 
<tr ng-repeat-end> 
    <td>{{item.author}}</td> 
    <td>{{item.date}}</td> 
</tr> 

ngRepeat docsに "特別リピート開始点と終了点" を参照してください。

そうでなければ、tbody要素にtrをラップし、それを繰り返すなど、いくつかの厄介なトリックに頼らなければなりません。

+1

ありがとうございます!できます! – cybaek

関連する問題