Reactive form Input with matInput

Asked

Viewed 18 times

0

I implemented an input text field that searches the elements in a list, this working is correct, but when typing the words it does not allow spaces in compound names that are already found in the list, as if forcing the selection of the same. It is possible to disable this behavior and allow free insertion and typing of elements, I tried to remove Binding from form control, but this way it loses the search.

INPUT FIELD

<input matInput placeholder="{{'INTERPOLAÇÃO }}" [formControl]="filterControl" [maxLength]="255">

VARIABLE DECLARATION ON THE FORM

filterControl = new FormControl();

FUNCTION

ngOnInit(){
    this.filteredOptions = this.filterControl.valueChanges.pipe(
      startWith<string | GenericFilter[]>(''),
      map((value) => (typeof value === 'string' ? value : this.lastFilter)),
      map((filter) => this.filter(filter))
    );
  }
  • I could not understand very well what is happening. You can improve the explanation, or make a simulation there at Stackblitz?

  • I think it was well explained already, but it was solved by implementing a timeout in the form, so when it opens normal with a '.open' it enables autofocus in the input field of the reactive form. Thank you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.