question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

md-select: add compareWith function

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:30
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
linuraducommented, May 19, 2017

Sounds good, regarding commit 😃 When will be the next release?

7reactions
reppnerscommented, Aug 14, 2017

Desperately need this 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using compareWith in Angular Material 2 multiple-select ...
The compareWith just literally compares objects by some given values and the checkboxes get selected, if it returns true . Once done, any...
Read more >
Select | Angular Material
(Additional information about using a custom compareWith function can be found in the Angular forms documentation). Select in a form. link code
Read more >
Use compareWith function from Angular Material mat-select ...
I'm trying to edit some member's firebase data with a mat-select component composed of different types. I'm not sure with my structure of...
Read more >
Angular Material options - Hardcoded value working ...
You have to put the .setValue function inside the subscription. this.listApiService.getListOfEventTypes().subscribe(data => { (data as Array<any>).
Read more >
Using a compareWith Function in Angular Material - YouTube
This video will show you how to use a compareWith function in Angular Material. Check out the source code from this sample at ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found