auto-complete
auto-complete copied to clipboard
How to change source on user input (listen to user input changes)
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.
i missed it in the documentation, its valueChange or ngModelChange.
thanks.
i was mistaken, valueChanged and ngModelChange only occurs when user selected an item.
Hi emostafa, were you able to solve this issue. I happen to have the same scenario and no able to do it yet.
@d4viddur4ngo unfortunately not yet. maybe i can work on writing a PR for fixing it in the weekend.
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([]);
}
}
I went with Keyboard events (keyup)="onInputChangedEvent($event)"