auto-complete icon indicating copy to clipboard operation
auto-complete copied to clipboard

How to change source on user input (listen to user input changes)

Open ishehata opened this issue 7 years ago • 6 comments

Current behavior

  • i am consuming api with paginated data, it only sends 20 items per page
  • when i enter a value in the auto-complete input, i couldn't find the needed item because it's not in the first 20

Expected/desired behavior

  • i need to make a new api call on user input to fetch more data from the api, so i guess i need some event to detect when input changes, i tried to use
(change)="inputChanged($event)"

on the input tag, but it didn't work.

ishehata avatar May 02 '17 18:05 ishehata

i missed it in the documentation, its valueChange or ngModelChange.

thanks.

ishehata avatar May 03 '17 21:05 ishehata

i was mistaken, valueChanged and ngModelChange only occurs when user selected an item.

ishehata avatar May 03 '17 22:05 ishehata

Hi emostafa, were you able to solve this issue. I happen to have the same scenario and no able to do it yet.

d4viddur4ngo avatar Jul 17 '17 19:07 d4viddur4ngo

@d4viddur4ngo unfortunately not yet. maybe i can work on writing a PR for fixing it in the weekend.

ishehata avatar Aug 20 '17 00:08 ishehata

There is Observable source. You can make use of this with the example of this from README.md http://plnkr.co/edit/ExzNSh?p=preview

  observableSource = (keyword: any): Observable<any[]> => {
    let url: string = 
      'https://maps.googleapis.com/maps/api/geocode/json?address='+keyword
    if (keyword) {
      return this.http.get(url)
        .map(res => {
          let json = res.json();
          return json.results;
        })
    } else {
      return Observable.of([]);
    }
  }

allenhwkim avatar Aug 20 '17 16:08 allenhwkim

I went with Keyboard events (keyup)="onInputChangedEvent($event)"

antajo avatar Mar 19 '19 16:03 antajo