-
Notifications
You must be signed in to change notification settings - Fork 26.6k
fix(forms): provide a method to compare options #13349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -82,6 +82,8 @@ export class SelectControlValueAccessor implements ControlValueAccessor { | |||
onChange = (_: any) => {}; | |||
onTouched = () => {}; | |||
|
|||
@Input() ngEquals: (o1: any, o2: any) => boolean = looseIdentical; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compareOptions/ equalOptions
?
compare implies 1, 0, -1 return... probably overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compare implies 1, 0, -1 return
yeah, this is why I chose equals
. We don't need to sort it.
LGTM, @kara could you please review ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a test for this?
@@ -82,6 +82,8 @@ export class SelectControlValueAccessor implements ControlValueAccessor { | |||
onChange = (_: any) => {}; | |||
onTouched = () => {}; | |||
|
|||
@Input() equalOptions: (o1: any, o2: any) => boolean = looseIdentical; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I like the idea of an optional equality method, but I don't think this name is very intuitive. Perhaps compareWith
? Discussed with @StephenFluin and we think that might fit the use case better.
<select [compareWith]="compareFn" [(ngModel)]="someProp">
...
</select>
@kara ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Is a release date known for this feature? It would help a lot :) |
@JosephBL this feature has been released for many months. (since |
Thanks a lot, I somehow missed it :$ |
Thanks a lot |
Faced an issue with this compare, if the select is inside the form /formgroup, with name , compare is not working |
As @chinthu said, if the select is in a form the compare function doesn't work properly. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Closes #13268 and #13274 / #13828 / #13884 #14121
Usage: