-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Error using ngOptions with objects containing circular references #11372
Comments
I can confirm and reproduce this error with Breeze entities, it was working correctly in beta5 but beta6 displays this behavior |
You're right, it was broken by this commit: 6a03ca2 |
#11448 offers a way to work around this issue, provided you aren't trying to use |
Having landed #11448 I can see that this bug appears to be fixed: http://jsfiddle.net/L9vqc9ew/ |
Yes, this bug is fixed in In any case, with the recent performance optimizations to |
👍 |
Make `angular.equals` handle circular references. Closes angular#11372
I think this is a better fix #11743 |
Using a deep watch caused Angular to enter an infinite recursion in the case that the model contains a circular reference. Using `$watchCollection` instead prevents this from happening. This change means that we will not re-render the directive when there is a change below the first level of properties on the model object. Making such a change is a strange corner case that is unlikely to occur in practice and the directive was not documented as supporting such a situation. The documentation has been updated to clarify this behaviour. Closes angular#11372 Closes angular#11653
Using a deep watch caused Angular to enter an infinite recursion in the case that the model contains a circular reference. Using `$watchCollection` instead prevents this from happening. This change means that we will not re-render the directive when there is a change below the first level of properties on the model object. Making such a change is a strange corner case that is unlikely to occur in practice and the directive is not designed to support such a situation. The documentation has been updated to clarify this behaviour. This is not a breaking change since in 1.3.x this scenario did not work at all. Compare 1.3.15: http://plnkr.co/edit/zsgnhflQ3M1ClUSrsne0?p=preview to snapshot: http://plnkr.co/edit/hI48vBc0GscyYTYucJ0U?p=preview Closes angular#11372 Closes angular#11653 Closes angular#11743
@petebacondarwin - I think the select documentation also needs to be updated as well - angular.js/src/ng/directive/select.js Lines 131 to 133 in abf59c2
|
Yes that block is not valid in that directive anyway, since it references |
@booleanbetrayal - Would you like to put together a PR with it removed/changed? |
Sure thing |
Using a deep watch caused Angular to enter an infinite recursion in the case that the model contains a circular reference. Using `$watchCollection` instead prevents this from happening. This change means that we will not re-render the directive when there is a change below the first level of properties on the model object. Making such a change is a strange corner case that is unlikely to occur in practice and the directive is not designed to support such a situation. The documentation has been updated to clarify this behaviour. This is not a breaking change since in 1.3.x this scenario did not work at all. Compare 1.3.15: http://plnkr.co/edit/zsgnhflQ3M1ClUSrsne0?p=preview to snapshot: http://plnkr.co/edit/hI48vBc0GscyYTYucJ0U?p=preview Closes angular#11372 Closes angular#11653 Closes angular#11743
The new
ngOptions
in Angular1.4-beta
doesn't handle objects containing circular references well.Steps to reproduce:
ng-options
withng-model
. At least one of the items in the source array must be a recursive object (such as a Breeze entity).http://jsfiddle.net/dubejf/tn102eh8/ (using
1.4.0-beta6
)The watcher of
ngModel
, set by thengOptionsDirective
, compares the selected item with the last value by deep equality (usingangular.equals
). When a recursive object is selected, this causes the stack to blow up (as described in #7724).Using
track by
doesn't alleviate the problem.This error is not reproducible in Angular 1.3.
The text was updated successfully, but these errors were encountered: