Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export class AutocompleteDisplayExample {
ngOnInit() {
this.filteredOptions = this.myControl.valueChanges
.pipe(
startWith({} as User),
map(user => user && typeof user === 'object' ? user.name : user),
startWith<string | User>(''),
map(value => typeof value === 'string' ? value : value.name),
map(name => name ? this.filter(name) : this.options.slice())
);
}
Expand All @@ -42,8 +42,8 @@ export class AutocompleteDisplayExample {
option.name.toLowerCase().indexOf(name.toLowerCase()) === 0);
}

displayFn(user: User): string {
return user ? user.name : user;
displayFn(user?: User): string | undefined {
return user ? user.name : undefined;
Copy link
Contributor Author

@rafaelss95 rafaelss95 Jan 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was doing the following:

displayFn(user?: User): string | undefined {
  return user ? user.name : user; <---
}

... however it doesn't go well in Stackblitz (maybe because there we don't have strictNullChecks).

}

}