2013-01-24 21 views
3

我使用嵌套的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> 

任何人都可以電話我是什麼原因導致這個錯誤以及如何解決它?

+2

你能發表這個jsfiddle嗎? – WiredPrairie

+1

「數據」應該是[「num1」,「2」]或{「num1」:「2」},因爲您擁有的不是有效的JavaScript。你還說你正在使用4 ng重複,但只顯示了兩個。請發佈更多代碼。 –

+0

看看你的'$ scope.data'結構,在你的嵌套'ng-repeat'中,'getdata'對象不會總是有'num1'的鍵。不知道這是否是從發佈到SO的翻譯錯誤,但是無論哪種方式,我們都可以使用更多代碼進行工作。 Mark Rajcok指出 – Justen

回答

1

JSON無效。另外,您的模板不會輸出任何可見內容,除非您在轉發器中放置了一些綁定標籤,例如{{ Company.Company.id }}

0

正如其他人已經說過的,數據是無效的。雖然它可能是有效的JSON,但它不是有效的JavaScript。我掀起了一個基於數據結構的深入實例,對有效的javascript進行了消毒,並且我沒有發現任何嵌套的重複錯誤。

當然,也有隻有兩個,因爲這是你在你的代碼片段已經證明以上。但它對這兩個方法很好,並且應該與其他嵌套重複一起工作。

http://plnkr.co/edit/z36YclsngdX9HozgdUkQ?p=preview