This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Passing in an a function to the ngOptions array clause that generates elements on the fly results in infinite $digest loop #9464
Labels
Milestone
Comments
#9419 may be partially related to what you want (since currently tracking expressions don't really work at all) |
drjokepu
added a commit
to drjokepu/angular.js
that referenced
this issue
Oct 7, 2014
… of objects in ngOptions ngOptions does not use the tracking expression when shallow watching array elements passed in to ngOptions. This is a problem if the elements passed in to ngOptions are generated on the fly and while the array elements identical in value, they are different instances; this leads to infinite digest loops. This change attempts to rectify the situation by shallow watching an array of trackFn(values) rather than the array of values themselves. Closes angular#9464
drjokepu
added a commit
to drjokepu/angular.js
that referenced
this issue
Oct 7, 2014
… of objects in ngOptions ngOptions does not use the tracking expression when shallow watching array elements passed in to ngOptions. This is a problem if the elements passed in to ngOptions are generated on the fly and while the array elements identical in value, they are different instances; this leads to infinite digest loops. This change attempts to rectify the situation by shallow watching an array of trackFn(values) rather than the array of values themselves. Closes angular#9464
drjokepu
added a commit
to drjokepu/angular.js
that referenced
this issue
Oct 7, 2014
… of objects in ngOptions ngOptions does not use the tracking expression when shallow watching array elements passed in to ngOptions. This is a problem if the elements passed in to ngOptions are generated on the fly and while the array elements identical in value, they are different instances; this leads to infinite digest loops. This change attempts to rectify the situation by shallow watching an array of trackFn(values) rather than the array of values themselves. Closes angular#9464
Yes, I forgot that I was working on 1.2.26 and not master, rookie mistake, thanks a lot! |
petebacondarwin
added a commit
to petebacondarwin/angular.js
that referenced
this issue
Jan 11, 2015
This is fixed by #10639 - see http://plnkr.co/edit/Q4EZDPCyAgUMKoWDPmrE?p=preview |
petebacondarwin
added a commit
to petebacondarwin/angular.js
that referenced
this issue
Jan 12, 2015
@petebacondarwin I just try the plunker demo with 1.3.15 and find that it still throw infdig errors. |
@ipoly the fix is only available in the 1.4.x branch |
@petebacondarwin the plunker demo doesn't work anymore, and I have the same issue of ngOptions |
@Jerryzhao-z, it is probably because that CI build artifacts are not available any more. Here is the same plnkr using v1.5.8: http://plnkr.co/edit/krNb7CjrQ55i1LeOTJ91?p=preview |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
AngularJS 1.2.22 (in particular, commit c286094) has changed the behaviour of ngOptions from deep watching to shallow watching the elements of the array. If the array and its elements are generated by a function on the fly, shallow watching will fail as even if the elements are identical, they are separate instances. This results in infinite $digest loops:
A tracking expression clause is supported by ngOptions that explicitly defines the expression that is used for comparing array elements. However, currently this is only used for identifying the selected item and not used for watching the elements of the array itself. I am suggesting extending the usage of this expression to be also used for differentiating of the array items themselves when shallow watching.
Reproducible: always
Browsers: Tested on Chrome 37, Safari 7.1
Operating System: OS X 10.9.5
Steps to reproduce:
This works fine on AngularJS 1.2.21 and earlier.
I am not really an Angular developer (or a real JavaScript developer for that matter), but I am going to submit a pull request with a spec test as well as a proposed solution that will illustrate how I would go about tackling the issue,
The text was updated successfully, but these errors were encountered: