Skip to content

Commit b4cb61b

Browse files
committed
address comments
1 parent b110cdd commit b4cb61b

File tree

17 files changed

+51
-5
lines changed

17 files changed

+51
-5
lines changed

src/lib/select/select.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ The select component is set up as a custom value accessor, so you can manipulate
1616
using any of the form directives from the core `FormsModule` or `ReactiveFormsModule`: `ngModel`,
1717
`formControl`, etc. As with native `<select>`, `<mat-select>` also supports a `compareWith`
1818
function. (Additional information about using a custom `compareWith` function can be found in the
19-
[angular forms documentation](https://angular.io/api/forms/SelectControlValueAccessor#caveat-option-selection)).
19+
[Angular forms documentation](https://angular.io/api/forms/SelectControlValueAccessor#caveat-option-selection)).
2020

2121
<!-- example(select-form) -->
2222

23+
`<mat-select>` also supports 2-way binding to the `value` property without the need for Angular
24+
forms.
25+
26+
<!-- example(select-value-binding) -->
27+
2328
### Form field features
2429

2530
There are a number of `<mat-form-field>` features that can be used with any `<mat-select>`. These
@@ -62,8 +67,8 @@ on the group.
6267

6368
### Selecting multiple options
6469

65-
By default the `<mat-select>` only supports selecting a single option at a time. However you can use
66-
the `multiple` property to allow the user to select multiple values at once. When using the
70+
By default, the `<mat-select>` only supports selecting a single option at a time. However, you can
71+
use the `multiple` property to allow the user to select multiple values at once. When using the
6772
`<mat-select>` in multiple selection mode, its value will be a sorted list of all selected values
6873
rather than a single value.
6974

@@ -78,7 +83,7 @@ If you want to display a custom trigger label inside a select, you can use the
7883

7984
### Disabling the ripple effect
8085

81-
By default when a user clicks on a `<mat-option>` a ripple animation is shown. This can be disabled
86+
By default, when a user clicks on a `<mat-option>`, a ripple animation is shown. This can be disabled
8287
by setting the `disableRipple` property on `<mat-select>`.
8388

8489
<!-- example(select-no-ripple) -->

src/material-examples/example-module.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ import {SelectOptgroupExample} from './select-optgroup/select-optgroup-example';
8585
import {SelectOverviewExample} from './select-overview/select-overview-example';
8686
import {SelectPanelClassExample} from './select-panel-class/select-panel-class-example';
8787
import {SelectResetExample} from './select-reset/select-reset-example';
88+
import {SelectValueBindingExample} from './select-vlaue-binding/select-value-binding-example';
8889
import {SidenavFabExample} from './sidenav-fab/sidenav-fab-example';
8990
import {SidenavOverviewExample} from './sidenav-overview/sidenav-overview-example';
9091
import {SlideToggleConfigurableExample} from './slide-toggle-configurable/slide-toggle-configurable-example';
@@ -542,6 +543,12 @@ export const EXAMPLE_COMPONENTS = {
542543
additionalFiles: null,
543544
selectorName: null
544545
},
546+
'select-value-binding': {
547+
title: 'Select with 2-way value binding ',
548+
component: SelectValueBindingExample,
549+
additionalFiles: null,
550+
selectorName: null
551+
},
545552
'sidenav-fab': {
546553
title: 'Sidenav with a FAB',
547554
component: SidenavFabExample,
@@ -755,6 +762,7 @@ export const EXAMPLE_LIST = [
755762
SelectOverviewExample,
756763
SelectPanelClassExample,
757764
SelectResetExample,
765+
SelectValueBindingExample,
758766
SidenavFabExample,
759767
SidenavOverviewExample,
760768
SlideToggleConfigurableExample,

src/material-examples/select-custom-trigger/select-custom-trigger-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {FormControl} from '@angular/forms';
55
@Component({
66
selector: 'select-custom-trigger-example',
77
templateUrl: 'select-custom-trigger-example.html',
8+
styleUrls: ['select-custom-trigger-example.css'],
89
})
910
export class SelectCustomTriggerExample {
1011
toppings = new FormControl();

src/material-examples/select-disabled/select-disabled-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {FormControl} from '@angular/forms';
55
@Component({
66
selector: 'select-disabled-example',
77
templateUrl: 'select-disabled-example.html',
8+
styleUrls: ['select-disabled-example.css'],
89
})
910
export class SelectDisabledExample {
1011
disableSelect = new FormControl(false);

src/material-examples/select-error-state-matcher/select-error-state-matcher-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export class MyErrorStateMatcher implements ErrorStateMatcher {
1414
@Component({
1515
selector: 'select-error-state-matcher-example',
1616
templateUrl: 'select-error-state-matcher-example.html',
17+
styleUrls: ['select-error-state-matcher-example.css'],
1718
})
1819
export class SelectErrorStateMatcherExample {
1920
selected = new FormControl('valid', [

src/material-examples/select-form/select-form-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {Component} from '@angular/core';
66
@Component({
77
selector: 'select-form-example',
88
templateUrl: 'select-form-example.html',
9+
styleUrls: ['select-form-example.css'],
910
})
1011
export class SelectFormExample {
1112
selectedValue: string;

src/material-examples/select-hint-error/select-hint-error-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {FormControl, Validators} from '@angular/forms';
55
@Component({
66
selector: 'select-hint-error-example',
77
templateUrl: 'select-hint-error-example.html',
8+
styleUrls: ['select-hint-error-example.css'],
89
})
910
export class SelectHintErrorExample {
1011
animalControl = new FormControl('', [Validators.required]);

src/material-examples/select-multiple/select-multiple-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {FormControl} from '@angular/forms';
55
@Component({
66
selector: 'select-multiple-example',
77
templateUrl: 'select-multiple-example.html',
8+
styleUrls: ['select-multiple-example.css'],
89
})
910
export class SelectMultipleExample {
1011
toppings = new FormControl();
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {Component} from '@angular/core';
22

3-
/** @title Select with cno option ripple */
3+
/** @title Select with no option ripple */
44
@Component({
55
selector: 'select-no-ripple-example',
66
templateUrl: 'select-no-ripple-example.html',
7+
styleUrls: ['select-no-ripple-example.css'],
78
})
89
export class SelectNoRippleExample {}

src/material-examples/select-optgroup/select-optgroup-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {FormControl} from '@angular/forms';
55
@Component({
66
selector: 'select-optgroup-example',
77
templateUrl: 'select-optgroup-example.html',
8+
styleUrls: ['select-optgroup-example.css'],
89
})
910
export class SelectOptgroupExample {
1011
pokemonControl = new FormControl();

src/material-examples/select-overview/select-overview-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {Component} from '@angular/core';
66
@Component({
77
selector: 'select-overview-example',
88
templateUrl: 'select-overview-example.html',
9+
styleUrls: ['select-overview-example.css'],
910
})
1011
export class SelectOverviewExample {
1112
foods = [

src/material-examples/select-panel-class/select-panel-class-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {FormControl} from '@angular/forms';
77
@Component({
88
selector: 'select-panel-class-example',
99
templateUrl: 'select-panel-class-example.html',
10+
styleUrls: ['select-panel-class-example.css'],
1011
})
1112
export class SelectPanelClassExample {
1213
panelColor = new FormControl('red');

src/material-examples/select-reset/select-reset-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Component} from '@angular/core';
44
@Component({
55
selector: 'select-reset-example',
66
templateUrl: 'select-reset-example.html',
7+
styleUrls: ['select-reset-example.css'],
78
})
89
export class SelectResetExample {
910
states = [
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/** No CSS for this example */
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<mat-form-field>
2+
<mat-select [(value)]="selected">
3+
<mat-option>None</mat-option>
4+
<mat-option value="option1">Option 1</mat-option>
5+
<mat-option value="option2">Option 2</mat-option>
6+
<mat-option value="option3">Option 3</mat-option>
7+
</mat-select>
8+
</mat-form-field>
9+
10+
<p>You selected: {{selected}}</p>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {Component} from '@angular/core';
2+
3+
/** @title Select with 2-way value binding */
4+
@Component({
5+
selector: 'select-value-binding-example',
6+
templateUrl: 'select-value-binding-example.html',
7+
styleUrls: ['select-value-binding-example.css'],
8+
})
9+
export class SelectValueBindingExample {
10+
selected = 'option2';
11+
}

0 commit comments

Comments
 (0)