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

Max Digest Iteration loop triggered by using ng-bind with a filter that returns an Array #9717

Closed
btesser opened this issue Oct 21, 2014 · 4 comments

Comments

@btesser
Copy link
Contributor

btesser commented Oct 21, 2014

When ng-bind is used, and the expression includes a filter that returns an array, angular enters an infinite digest loop and eventually cuts out after the 10 digest limit. I looked at the source and the issue is caused by the fact that ng-bind never uses object equality (angular.equals) to compare the new value and the old value in the watcher, rather since the filter is returning a new array, the old array is never equal and an infinite digest loop is caused.

The same expression will work if you use double curlies for binding rather than ng-bind

See plnkr which shows the bug in action.

http://plnkr.co/edit/t6B3uz

@btesser
Copy link
Contributor Author

btesser commented Oct 21, 2014

This bug exists in both 1.2.26 and 1.3.0

@Narretz
Copy link
Contributor

Narretz commented Oct 22, 2014

Interesting. angular.equals() might be too expensive, though.

@btesser
Copy link
Contributor Author

btesser commented Oct 22, 2014

The alternative would be to convert the array to a string within ngbind and
compare the string values. Thereby behavior whenever curly brackets is
angular.equals so ngbind should probably match.
On Oct 22, 2014 9:27 AM, "Narretz" notifications@github.com wrote:

Interesting. angular.equals() might be too expensive, though.


Reply to this email directly or view it on GitHub
#9717 (comment).

@Narretz
Copy link
Contributor

Narretz commented May 28, 2018

Instead of binding the array directly, convert it to a string with a filter first.

@Narretz Narretz closed this as completed May 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants