-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(select): add ability to customize the selected value label
Adds the `md-select-label` directive which allows users to customize the selected value. E.g. it is now possible to do something like this, if the user wanted to reverse the selected label for some reason: ```ts <md-select placeholder="Food" [formControl]="control" #select="mdSelect"> <md-select-label> {{ select.selected?.viewValue.split('').reverse().join('') }} </md-select-label> <md-option *ngFor="let food of foods" [value]="food.value"> {{ food.viewValue }} </md-option> </md-select> ``` Fixes #2275.
- Loading branch information
Showing
9 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/** No CSS for this example */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<md-select placeholder="Favorite food" #select="mdSelect"> | ||
<md-select-label>You have selected: {{ select.selected?.viewValue }}</md-select-label> | ||
<md-option *ngFor="let food of foods" [value]="food.value"> | ||
{{ food.viewValue }} | ||
</md-option> | ||
</md-select> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
|
||
@Component({ | ||
selector: 'select-label-example', | ||
templateUrl: './select-label-example.html', | ||
}) | ||
export class SelectLabelExample { | ||
foods = [ | ||
{value: 'steak-0', viewValue: 'Steak'}, | ||
{value: 'pizza-1', viewValue: 'Pizza'}, | ||
{value: 'tacos-2', viewValue: 'Tacos'} | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {Directive} from '@angular/core'; | ||
|
||
/** | ||
* Allows the user to customize the label that is displayed `md-select` has a value. | ||
*/ | ||
@Directive({ | ||
selector: 'md-select-label, mat-select-label' | ||
}) | ||
export class MdSelectLabel { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters