/
githubmirror
/
components
Обзор
Документация
Войти
/
githubmirror
/
components
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/components-examples/material/autocomplete/autocomplete-require-selection/autocomplete-require-selection-example.ts
32 строки
1 KB
Michael Small
docs: convert auto/badge/btn/sheet/btntoggle/input to signals (#33492)
06 июл 2026, 10:27
Не верифицирован
06 июл 2026, 10:27
9edf12d
Код
Авторство
О чём код?
import {Component, ElementRef, signal, viewChild} from '@angular/core'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {MatAutocompleteModule} from '@angular/material/autocomplete'; import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; /** * @title Require an autocomplete option to be selected */ @Component({ selector: 'autocomplete-require-selection-example', templateUrl: 'autocomplete-require-selection-example.html', styleUrl: 'autocomplete-require-selection-example.css', imports: [ FormsModule, MatFormFieldModule, MatInputModule, MatAutocompleteModule, ReactiveFormsModule, ], }) export class AutocompleteRequireSelectionExample { input = viewChild.required<ElementRef<HTMLInputElement>>('input'); myControl = new FormControl(''); options: string[] = ['One', 'Two', 'Three', 'Four', 'Five']; filteredOptions = signal<string[]>(this.options.slice()); filter(): void { const filterValue = this.input().nativeElement.value.toLowerCase(); this.filteredOptions.set(this.options.filter(o => o.toLowerCase().includes(filterValue))); } }