1

I have three jsFiddles that demonstrate my problem: 1)Not working 2)Shows the array 3)Working with small array

<div style="display:inline-block;">
    <div ng-repeat="date in [0,1,2,3]" ng-bind="date" class="day"></div>
</div>

Part of my controller:

$scope.month_calendar = function (num) {
    var arr = [];
    for (var i = 0; i < 12; i++) {
        arr.push($scope.year_calendar.slice(i * 35, (i + 1) * 35));
$scope.monthly_calendar = $scope.month_calendar($scope.month);

I am trying to make a calendar with ng-repeat where the dates are repeated. When I use a short little arbitrary array it works. When I use the monthly_calendar array it doesn't work, but I can also just print out the monthly_calendar array and it changes when the month changes. Does anyone know why my array won't work in ng-repeat?

1 Answer 1

2

AngularJS does not allow duplicates in ng-repeat directive. To fix that use the following:

... ng-repeat="date in monthly_calendar track by $index" ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.