3

i used nested ng-repeat to display my data in html page.

it is throwing an error

Error: Error: 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations

but this error doesn't affect my functionality.i was searching for an answer for this problem but i didn't get the correct answer thats y i posted this question here.

i didn't know whether my json data structure causes this error, but i can't change its structure.

here is my sample json data

    //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>

can anyone tel me what causes this error and how to resolve it?

Mark Rajcok
  • 362,217
  • 114
  • 495
  • 492
JSAddict
  • 12,407
  • 7
  • 29
  • 49
  • 2
    Could you post a jsfiddle of this? – WiredPrairie Jan 24 '13 at 12:03
  • 1
    Is "data" supposed to be ["num1", "2"] or {"num1": "2"}, because what you have isn't valid JavaScript. You also say you're using 4 ng-repeats, but only two are shown. Please post more code. – Mark Rajcok Jan 24 '13 at 18:49
  • Looking at your `$scope.data` structure, in your nested `ng-repeat`, the `getdata` object won't always have the key of `num1`. Not sure if this is a translated error from posting to SO, but either way we could use some more code to work from. – Justen Jan 24 '13 at 20:29
  • as Mark Rajcok pointed out, your data array is wrong. – Jigar Patel Jan 25 '13 at 02:49
  • @MarkRajcok updated the question. yes i m using 4 ng-repeats in that page. but because of this ng-repeat it throws an error. i just wanted u to know that i am using more ng-repeats in a single page. – JSAddict Jan 25 '13 at 08:30
  • 2
    @Prashanth We really need a jsfiddle or plunker so we can look at your code running and see the error in context. – Josh David Miller Jan 28 '13 at 20:33
  • @JoshDavidMiller sorry i m not allowed to post my code. i tried a sample code which is almost similar like that in fiddle but it is not throwing errors. – JSAddict Jan 30 '13 at 05:54
  • @Prashanth We neither need nor want *all* of your code, but we need *something* that throws an error or just doesn't work. If you tried it in a fiddle and it worked, then keep adding more of your code until it doesn't anymore. When it throws the error, you know what's causing it and can try from there. But without some code, there's nothing the rest of us can do. – Josh David Miller Jan 30 '13 at 05:59
  • @Prashanth There's nothing in the code that you posted that should be causing this error. http://jsfiddle.net/QfERt/15/ -- works fine. This error is usually caused when you have a watcher on some expression (in controller or directive) that modifies the value of that expression, which results in an infinite loop. Please review all your watchers. – pavelgj Jan 31 '13 at 21:34

3 Answers3

1

That JSON is not valid. Also, your template is not going to output anything visible unless you put some bind tags in the repeater like {{ Company.Company.id }} for example.

Josh Sherick
  • 2,161
  • 3
  • 20
  • 37
Jignesh.Raj
  • 5,776
  • 4
  • 27
  • 56
0

This could be because you are initializing objects in views inside ng-repeat. I had similar problem because of that. Please see this link

Error: 10 $digest() iterations reached. Aborting! with dynamic sortby predicate

Community
  • 1
  • 1
Chubby Boy
  • 30,942
  • 19
  • 47
  • 47
0

As others have already stated, the data is invalid. While it may be valid JSON, it's not valid javascript. I whipped up a plunker example based on the data structure, sanitized to valid javascript, and I don't have any errors with nested ng repeats.

Granted, there are only two, since that's all you've shown in your code snippet above. But it works just fine with these two, and should work equally fine with additional nested repeats.

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

Will Vincent
  • 331
  • 2
  • 6
  • 10