我使用嵌套的ng-repeat在html頁面中顯示我的數據。錯誤,因爲ng-repeat在angularjs中
它拋出一個錯誤
Error: Error: 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations
,但這個錯誤並不影響我functionality.i正在尋找這個問題的答案,但我沒有得到正確的答案,多數民衆贊成易張貼了這個問題,在這裏。
我不知道我的JSON數據結構是否會導致這個錯誤,但我不能改變其結構。
這裏是我的示例JSON數據
//In controller
for (var i = 1; i <= 31; i++) {
$scope.daysofmonth.push({day:i}); // daysofmonth.day->1,2,3...
}
for(var j=0; j<$scope.daysofmonth.length; j++) {
$scope.daysofmonth[j].events = [ // creating 31 arrays for events
{"name":"T", "count":0,"data":[{
"startDate":"01/25/2013",
"startTime":"00:00",
"endDate":"01/26/2013",
"endTime":"00:00",
"type":"m",
"status":"Not Started",
"title":"Demo to Client",
"description":"Application demo"
}]},
{"name":"I", "count":0,"data":[...]} // same as previous
];
//left some of the business logic
}
//In html file
<div class="{{box | today:year+'-'+month+'-'+dayofmonth.day:dayofmonth.day}}" ng-repeat="dayofmonth in daysofmonth" >
<span class="days">{{ dayofmonth.day }}</span>
<span class="events-list">
<div ng-repeat="eve in dayofmonth.events" >
{{ eve.count + eve.name }}
</div>
</span>
</div>
任何人都可以電話我是什麼原因導致這個錯誤以及如何解決它?
你能發表這個jsfiddle嗎? – WiredPrairie
「數據」應該是[「num1」,「2」]或{「num1」:「2」},因爲您擁有的不是有效的JavaScript。你還說你正在使用4 ng重複,但只顯示了兩個。請發佈更多代碼。 –
看看你的'$ scope.data'結構,在你的嵌套'ng-repeat'中,'getdata'對象不會總是有'num1'的鍵。不知道這是否是從發佈到SO的翻譯錯誤,但是無論哪種方式,我們都可以使用更多代碼進行工作。 Mark Rajcok指出 – Justen