#SearchInputBox guestion

4 messages · Page 1 of 1 (latest)

short pebble
#

What event is (key)?
And what you're trying to achieve exactly?
Please copy/paste your real code, don't try to replicate it.

short pebble
#

Please take some time to re-read your questions before posting.
It's really hard to read them.
Do you want the search box to automatically trigger an operation (probably a GET request) after every keystroke but only if the user has put in at least 3 characters?

short pebble
#

You can make it really easy leveraging ReactiveForms.

  • bind that input to a FormControl
  • subscribe to its valueChanges observable
  • pipe to a filter checking value.length > 2
  • switchMap to the http request
  • do what you want with emitted value
#

You don't need flags and other strange things.
And you can even refine its behaviour adding some debounce to avoid cloggin the network with many requests