[英]Angular ng-repeat not working with my array
I have three jsFiddles that demonstrate my problem: 1) Not working 2) Shows the array 3) Working with small array 我有三个jsFiddles演示我的问题:1) 不工作 2) 显示数组 3) 使用小型数组
<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. 我正在尝试使用ng-repeat制作一个重复日期的日历。 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.
当我使用monthly_calendar数组时,它不起作用,但是我也可以只打印出monthly_calendar数组,当月份改变时,它也会改变。 Does anyone know why my array won't work in ng-repeat?
有谁知道为什么我的阵列不能在ng-repeat中工作?
AngularJS does not allow duplicates in ng-repeat
directive. AngularJS 不允许在
ng-repeat
指令中ng-repeat
。 To fix that use the following: 要解决此问题,请使用以下命令:
... ng-repeat="date in monthly_calendar track by $index" ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.