Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Nested ng-repeat: deeper than 1 level comparison between last and current arrays? #2033

Closed
ashtuchkin opened this issue Feb 19, 2013 · 2 comments

Comments

@ashtuchkin
Copy link
Contributor

This code works great:

<div ng-repeat="a in []">
</div>

This code will lead to "10 $digest iterations" error (plunkr):

<div ng-repeat="a in [[]]">
  <div ng-repeat="b in a">
  </div>
</div>

The difference is that, although the array object is created on every $digest cycle, the comparison goes 1 level deep, comparing the items in last and current arrays, not the arrays themselves. When we go nested with N levels, we need to compare N levels of arrays down, so that the array objects themselves didn't matter, only the actual objects inside.

Why is this needed? Try to write an array filter that works with array-of-arrays, keeping all returned array objects the same between $digest iterations.

Real-world example: Suppose need to show items in groups of 3. We write a nested ng-repeat and simple splitter filter -> 10 $digest iterations error -> minus 3 hours of life and a much deeper understanding of Angular insides.

This might be related to #1389, not sure.

@btford btford closed this as completed Aug 24, 2013
@btford
Copy link
Contributor

btford commented Aug 24, 2013

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

Thanks!

@lyda
Copy link

lyda commented Feb 7, 2016

This issue still persists. It would be nice if filters like this could work:

https://stackoverflow.com/questions/35255705/angularjs-can-i-use-a-filter-to-chunk-an-array-in-ng-repeat

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants