indrimuska / angular-selector

A native AngularJS directive that transform a simple <select> box into a full html select with typeahead.
http://indrimuska.github.io/angular-selector
MIT License
96 stars 36 forks source link

cancel previous request #26

Closed sandeep-rajbhandari closed 8 years ago

sandeep-rajbhandari commented 8 years ago

In your example of "Remote fetching with custom service" as i start writing the name of country it sends requests for every new letter typed.The request is as follows: search?text=n
search?text=ne
search?text=nep search?text=nepa
search?text=nepal So what needs to be done if I want to cancel previous remote fetching request with new request requested?

indrimuska commented 8 years ago

Hi @sandeep-rajbhandari, I don't know if I've totally understand your question. When you type some text in the selector - using any remote configuration - you send a request anytime the input changes. Doing that, you'll be able to perform filtering in your backend system. You can't cancel previous requests, but you can delay your requests and then accept just the last one, something similar to debounce for text input.

indrimuska commented 8 years ago

I'm going to close this, since it could be achieved by using input debounce.

Nishchit14 commented 8 years ago

@indrimuska

I think @sandeep-rajbhandari is trying to request for debounce property as we discussed earlier. Request will only send after we stop writing. Debounce period should be custom in ms like debounce = 1000 will watch typing, if not get any event of typing within 1 second then call request.

Angular providing this as n-model-options, You can find it here debounce.

indrimuska commented 8 years ago

FYI latest release v1.3.10 has a new debounce property.