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

fix(ngOptions): use reference check only when not using trackBy #11996

Closed
wants to merge 1 commit into from

Conversation

seaster
Copy link
Contributor

@seaster seaster commented Jun 1, 2015

Change the check on changed value for ngOptions to ensure that a reference check is only done
when trackBy is not used. Previously, if trackBy was being used but the values of the objects were
equal a reference check was then used which would cause the check to be true if the objects had
different memory references but the values were equal. This can cause issues with forms being
marked dirty when the value of the model as not actually changed.

Closes #11936

scope.arr[0] = {id: 10, label: 'ten'};
});

// update render due to equality watch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be removed

@Narretz
Copy link
Contributor

Narretz commented Jun 1, 2015

LGTM, apart from the two comments I left.

Change the check on changed value for ngOptions to ensure that a reference check is only done
when trackBy is not used.  Previously, if trackBy was being used but the values of the objects were
equal a reference check was then used which would cause the check to be true if the objects had
different memory references but the values were equal.  This can cause issues with forms being
marked dirty when the value of the model as not actually changed.

Closes angular#11936
@seaster seaster force-pushed the ngOptions-trackBy-Fix branch from 13589d1 to 746dbec Compare June 1, 2015 18:38
@petebacondarwin
Copy link
Contributor

LGTM - feel free to merge

@seaster seaster deleted the ngOptions-trackBy-Fix branch June 2, 2015 14:10
netman92 pushed a commit to netman92/angular.js that referenced this pull request Aug 8, 2015
Change the check on changed value for ngOptions to ensure that a reference check is only done
when trackBy is not used.  Previously, if trackBy was being used but the values of the objects were
equal a reference check was then used which would cause the check to be true if the objects had
different memory references but the values were equal.  This can cause issues with forms being
marked dirty when the value of the model as not actually changed.

Closes angular#11936
Closes angular#11996
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ngOptions with "track by" triggers ngChange when ngModel did not change
4 participants