Skip to content

Commit 8a42b98

Browse files
Splaktarmmalerba
andcommitted
docs(material/autocomplete): fix exception on page load (#17956)
use a proper label instead of a placeholder Fixes #17955 Co-authored-by: mmalerba <[email protected]>
1 parent e746895 commit 8a42b98

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/components-examples/material/autocomplete/autocomplete-display/autocomplete-display-example.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
<form class="example-form">
22
<mat-form-field class="example-full-width">
3-
<input type="text"
4-
placeholder="Assignee"
5-
aria-label="Assignee"
6-
matInput
7-
[formControl]="myControl"
8-
[matAutocomplete]="auto">
3+
<mat-label>Assignee</mat-label>
4+
<input type="text" matInput [formControl]="myControl" [matAutocomplete]="auto">
95
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
106
<mat-option *ngFor="let option of filteredOptions | async" [value]="option">
117
{{option.name}}

src/components-examples/material/autocomplete/autocomplete-display/autocomplete-display-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class AutocompleteDisplayExample implements OnInit {
3434
}
3535

3636
displayFn(user: User): string {
37-
return user.name;
37+
return user && user.name ? user.name : '';
3838
}
3939

4040
private _filter(name: string): User[] {

0 commit comments

Comments
 (0)