-
Notifications
You must be signed in to change notification settings - Fork 27.5k
ng-repeat does not work with primitive types #933
Comments
Have detected these errors related to this one: Will try to submit a fix soon ... |
the committed tests succeed even without the src changes, so the tests don't test this particular issue. reopening. |
This commits adds test for angular#933 and simplifies the implementation of the fix Closes angular#933
In cases when we reuse elements in a repeater but associate them with a new scope (see angular#933 - repeating over array of primitives) it's possible for the internal ngModel state and the scope state to get out of sync. This change ensure that the two are always sync-ed up even in cases where we reassociate an element with a different (but similar) scope. In the case of repeating over array of primitives it's still possible to run into issue if we iterate over primitives and use form controls or similar widgets without ngModel - oh well, we'd likely need a special repeater for primitives to deal with this properly, even then there might be cornercases. Closes angular#933
I'm reverting changes that were originally done to ngRepeat to fix angular#933, because these are now not necessary after the previous changes to keep ngModel always synced with the DOM.
I'm keeping this in for future reference. The issue with this solution is that if we shift() the first item in the array, the whole repeater DOM will be rebuilt from scratch, we need to do better than that.
I'm reverting changes that were originally done to ngRepeat to fix #933, because these are now not necessary after the previous changes to keep ngModel always synced with the DOM.
I'm keeping this in for future reference. The issue with this solution is that if we shift() the first item in the array, the whole repeater DOM will be rebuilt from scratch, we need to do better than that.
In cases when we reuse elements in a repeater but associate them with a new scope (see #933 - repeating over array of primitives) it's possible for the internal ngModel state and the scope state to get out of sync. This change ensure that the two are always sync-ed up even in cases where we reassociate an element with a different (but similar) scope. In the case of repeating over array of primitives it's still possible to run into issue if we iterate over primitives and use form controls or similar widgets without ngModel - oh well, we'd likely need a special repeater for primitives to deal with this properly, even then there might be cornercases. Closes #933
I'm reverting changes that were originally done to ngRepeat to fix #933, because these are now not necessary after the previous changes to keep ngModel always synced with the DOM.
I'm keeping this issue open because as @petebacondarwin noticed even the existing fixes result in loss of focus when primitive array elements are being edited in place: #1602 (comment) |
Hello i'm new with angular. Is this bug in direct relation with this issue ? (the content is hidden, take a look to the class of the ngRepeat) If not I should probably open a new issue. |
This issue is fixed in master: http://plnkr.co/edit/fikTevt0bGALj2aYFhj2?p=preview |
http://jsfiddle.net/alexpetrov/tRxzr/
The text was updated successfully, but these errors were encountered: