Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1x 5x 5x 5x 7x 7x 7x | import { AsyncPipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; import { ReactiveFormsModule } from '@angular/forms'; import { MatAutocompleteModule } from '@angular/material/autocomplete'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { DynamicFormCombobox, DynamicFormElementComponent, DynamicFormInputBase, DynamicFormValidationService } from '@dynamic-forms/core'; import { Observable } from 'rxjs'; import { map, startWith } from 'rxjs/operators'; @Component({ selector: 'mat-dynamic-form-combobox', templateUrl: './dynamic-form-combobox.component.html', imports: [AsyncPipe, ReactiveFormsModule, DynamicFormElementComponent, MatFormFieldModule, MatInputModule, MatAutocompleteModule], }) export class MatDynamicFormComboboxComponent extends DynamicFormInputBase<DynamicFormCombobox> implements OnInit { filteredOptions: Observable<string[]>; constructor(protected override validationService: DynamicFormValidationService) { super(validationService); } ngOnInit(): void { this.filteredOptions = this.control.valueChanges.pipe( startWith(''), map(value => this.getFilteredOptions(value)), ); } private getFilteredOptions(value: string): string[] { const valueNormalized = value ? value.toUpperCase() : null; return valueNormalized ? this.input.options?.filter(option => option.toUpperCase().includes(valueNormalized)) : this.input.options; } } |