-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main - 0296713 fix(material/select): add opt-in input that allows sel…
…ection of nullable options (#30142)
- Loading branch information
Showing
26 changed files
with
211 additions
and
41 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
19 changes: 19 additions & 0 deletions
19
...ghlighted/material/select/select-selectable-null/select-selectable-null-example-html.html
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,19 @@ | ||
<span class="hljs-tag"><<span class="hljs-name">h4</span>></span>mat-select allowing selection of nullable options<span class="hljs-tag"></<span class="hljs-name">h4</span>></span> | ||
<span class="hljs-tag"><<span class="hljs-name">mat-form-field</span>></span> | ||
<span class="hljs-tag"><<span class="hljs-name">mat-label</span>></span>State<span class="hljs-tag"></<span class="hljs-name">mat-label</span>></span> | ||
<span class="hljs-tag"><<span class="hljs-name">mat-select</span> [(<span class="hljs-attr">ngModel</span>)]=<span class="hljs-string">"value"</span> <span class="hljs-attr">canSelectNullableOptions</span>></span> | ||
@for (option of options; track option) { | ||
<span class="hljs-tag"><<span class="hljs-name">mat-option</span> [<span class="hljs-attr">value</span>]=<span class="hljs-string">"option.value"</span>></span>{{option.label}}<span class="hljs-tag"></<span class="hljs-name">mat-option</span>></span> | ||
} | ||
<span class="hljs-tag"></<span class="hljs-name">mat-select</span>></span> | ||
<span class="hljs-tag"></<span class="hljs-name">mat-form-field</span>></span> | ||
|
||
<span class="hljs-tag"><<span class="hljs-name">h4</span>></span>mat-select with default configuration<span class="hljs-tag"></<span class="hljs-name">h4</span>></span> | ||
<span class="hljs-tag"><<span class="hljs-name">mat-form-field</span>></span> | ||
<span class="hljs-tag"><<span class="hljs-name">mat-label</span>></span>State<span class="hljs-tag"></<span class="hljs-name">mat-label</span>></span> | ||
<span class="hljs-tag"><<span class="hljs-name">mat-select</span> [(<span class="hljs-attr">ngModel</span>)]=<span class="hljs-string">"value"</span>></span> | ||
@for (option of options; track option) { | ||
<span class="hljs-tag"><<span class="hljs-name">mat-option</span> [<span class="hljs-attr">value</span>]=<span class="hljs-string">"option.value"</span>></span>{{option.label}}<span class="hljs-tag"></<span class="hljs-name">mat-option</span>></span> | ||
} | ||
<span class="hljs-tag"></<span class="hljs-name">mat-select</span>></span> | ||
<span class="hljs-tag"></<span class="hljs-name">mat-form-field</span>></span> |
21 changes: 21 additions & 0 deletions
21
...highlighted/material/select/select-selectable-null/select-selectable-null-example-ts.html
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,21 @@ | ||
<span class="hljs-keyword">import</span> {Component} <span class="hljs-keyword">from</span> <span class="hljs-string">'@angular/core'</span>; | ||
<span class="hljs-keyword">import</span> {FormsModule} <span class="hljs-keyword">from</span> <span class="hljs-string">'@angular/forms'</span>; | ||
<span class="hljs-keyword">import</span> {MatInputModule} <span class="hljs-keyword">from</span> <span class="hljs-string">'@angular/material/input'</span>; | ||
<span class="hljs-keyword">import</span> {MatSelectModule} <span class="hljs-keyword">from</span> <span class="hljs-string">'@angular/material/select'</span>; | ||
<span class="hljs-keyword">import</span> {MatFormFieldModule} <span class="hljs-keyword">from</span> <span class="hljs-string">'@angular/material/form-field'</span>; | ||
|
||
<span class="hljs-comment">/** <span class="hljs-doctag">@title </span>Select with selectable null options */</span> | ||
<span class="hljs-meta">@Component</span>({ | ||
<span class="hljs-attr">selector</span>: <span class="hljs-string">'select-selectable-null-example'</span>, | ||
<span class="hljs-attr">templateUrl</span>: <span class="hljs-string">'select-selectable-null-example.html'</span>, | ||
<span class="hljs-attr">imports</span>: [MatFormFieldModule, MatSelectModule, MatInputModule, FormsModule], | ||
}) | ||
<span class="hljs-keyword">export</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SelectSelectableNullExample</span> </span>{ | ||
<span class="hljs-attr">value</span>: <span class="hljs-built_in">number</span> | <span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>; | ||
options = [ | ||
{<span class="hljs-attr">label</span>: <span class="hljs-string">'None'</span>, <span class="hljs-attr">value</span>: <span class="hljs-literal">null</span>}, | ||
{<span class="hljs-attr">label</span>: <span class="hljs-string">'One'</span>, <span class="hljs-attr">value</span>: <span class="hljs-number">1</span>}, | ||
{<span class="hljs-attr">label</span>: <span class="hljs-string">'Two'</span>, <span class="hljs-attr">value</span>: <span class="hljs-number">2</span>}, | ||
{<span class="hljs-attr">label</span>: <span class="hljs-string">'Three'</span>, <span class="hljs-attr">value</span>: <span class="hljs-number">3</span>}, | ||
]; | ||
} |
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
19 changes: 19 additions & 0 deletions
19
...xamples-source/material/select/select-selectable-null/select-selectable-null-example.html
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,19 @@ | ||
<h4>mat-select allowing selection of nullable options</h4> | ||
<mat-form-field> | ||
<mat-label>State</mat-label> | ||
<mat-select [(ngModel)]="value" canSelectNullableOptions> | ||
@for (option of options; track option) { | ||
<mat-option [value]="option.value">{{option.label}}</mat-option> | ||
} | ||
</mat-select> | ||
</mat-form-field> | ||
|
||
<h4>mat-select with default configuration</h4> | ||
<mat-form-field> | ||
<mat-label>State</mat-label> | ||
<mat-select [(ngModel)]="value"> | ||
@for (option of options; track option) { | ||
<mat-option [value]="option.value">{{option.label}}</mat-option> | ||
} | ||
</mat-select> | ||
</mat-form-field> |
21 changes: 21 additions & 0 deletions
21
.../examples-source/material/select/select-selectable-null/select-selectable-null-example.ts
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,21 @@ | ||
import {Component} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {MatInputModule} from '@angular/material/input'; | ||
import {MatSelectModule} from '@angular/material/select'; | ||
import {MatFormFieldModule} from '@angular/material/form-field'; | ||
|
||
/** @title Select with selectable null options */ | ||
@Component({ | ||
selector: 'select-selectable-null-example', | ||
templateUrl: 'select-selectable-null-example.html', | ||
imports: [MatFormFieldModule, MatSelectModule, MatInputModule, FormsModule], | ||
}) | ||
export class SelectSelectableNullExample { | ||
value: number | null = null; | ||
options = [ | ||
{label: 'None', value: null}, | ||
{label: 'One', value: 1}, | ||
{label: 'Two', value: 2}, | ||
{label: 'Three', value: 3}, | ||
]; | ||
} |
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
Oops, something went wrong.