モデルからテンプレートにデータを挿入しようとしていますが、7回繰り返すごとに新しいテーブル行を追加したいと思います。strignベースのテンプレートでは、反復インデックスとモジュロを使用して非常に簡単に実行できましたが、angularのDOMテンプレートを使用してこれを実行する方法を完全に理解することはできません。
HTMLは次のとおりです。
<div ng-controller="MyCtrl">
<table cellspacing="0" cellpadding="0">
<colgroup span="7"></colgroup>
<tbody>
<tr class="days">
<th scope="col" title="Monday">Mon</th>
<th scope="col" title="Tuesday">Tue</th>
<th scope="col" title="Wednesday">Wed</th>
<th scope="col" title="Thursday">Thu</th>
<th scope="col" title="Friday">Fri</th>
<th scope="col" title="Saturday">Sat</th>
<th scope="col" title="Sunday">Sun</th>
</tr>
<tr>
<td ng-repeat="date in dates">
{{ date }}
<!-- After seven iterations a new `<tr>` should be aded -->
</td>
</tr>
</tbody>
</table>
</div>
そして、JavaScriptは次のようになります。
myApp = this.angular.module('myApp', []);
var monthDays = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1516, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31];
myApp.controller('MyCtrl', function($scope) {
return $scope.dates = monthDays;
});
ここでJSFiddleのコードを表示できます:http://jsfiddle.net/3zhbB/2/