We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 310da32 commit c7b1e27Copy full SHA for c7b1e27
src/material-examples/autocomplete-display/autocomplete-display-example.ts
@@ -31,8 +31,8 @@ export class AutocompleteDisplayExample {
31
ngOnInit() {
32
this.filteredOptions = this.myControl.valueChanges
33
.pipe(
34
- startWith({} as User),
35
- map(user => user && typeof user === 'object' ? user.name : user),
+ startWith<string | User>(''),
+ map(value => typeof value === 'string' ? value : value.name),
36
map(name => name ? this.filter(name) : this.options.slice())
37
);
38
}
@@ -42,8 +42,8 @@ export class AutocompleteDisplayExample {
42
option.name.toLowerCase().indexOf(name.toLowerCase()) === 0);
43
44
45
- displayFn(user: User): string {
46
- return user ? user.name : user;
+ displayFn(user?: User): string | undefined {
+ return user ? user.name : undefined;
47
48
49
0 commit comments