Currently, md-select values are compared by object reference. This is a bit inflexible. We want to allow people to compare options by a custom comparator in case they only care about the object's ID or some other property.
Example markup:
<md-select placeholder="Food" [(ngModel)]="food" [compareWith]="compareById">
<md-option *ngFor="let food of foods" [value]="food"> {{ food.name }} </md-option>
</md-select>
compareById(obj1, obj2) {
return obj1.id === obj2.id;
}
This will be parallel to functionality being added to native selects in core.
@kara is this still being considered?
What news?
Sounds good, regarding commit :) When will be the next release?
Any update on this? Looks like there's a fix in a forked branch but not submitted for PR / review yet.
It looks like there is a PR, but it now has a merge conflict: https://github.com/angular/material2/pull/4540
Has anyone implemented a workaround for this issue?
I have PR #4540 open. I'm pretty good about rebasing it pretty often, so if you really need the feature, you could build against my branch. I'm not sure when/if they plan on merging it into master.
Desperately need this 馃憤
For me only solved when I've change the ngModel
to value
. Like:
<md-select placeholder="Food" [(value)]="food" [compareWith]="compareById">
<md-option *ngFor="let food of foods" [value]="food"> {{ food.name }} </md-option>
</md-select>
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Sounds good, regarding commit :) When will be the next release?