Skip to content

Instantly share code, notes, and snippets.

@amboy00
Created January 20, 2013 00:53
Show Gist options
  • Save amboy00/4576081 to your computer and use it in GitHub Desktop.
Save amboy00/4576081 to your computer and use it in GitHub Desktop.
In Angular.js, push x number of rows into grouped repeaters. Like 7 days in a week, 30 days in a month for example.
window.myApp = this.angular.module('myApp', ['ngSanitize']);
var monthDays = ['array stuff'];
myApp.controller('MyCtrl', function($scope) {
var dates = [];
for (var i = 0; i < monthDays.length; i++ ) {
if (i % 5 == 0) dates.push([]);
dates[dates.length-1].push(monthDays[i]);
}
return $scope.dates = dates;
});
<div ng-repeat="days in dates">
<div ng-repeat="day in days">
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment