1

I am using angularjs 1.5 and while using md-autocomplete with $http request to fetch the list if i press enter key when some http calls are in pending state then all the pending requests are getting cancelled automatically.

here is my code snippet:

HTML:

<md-autocomplete md-selected-item="selectedItem" md-search-text="searchText" md-items="item in querySearch(searchText)">
  <md-item-template>
    <span md-highlight-text="searchText">{{item}}</span>
  </md-item-template>
</md-autocomplete>

JS:

function querySearch (searchText) {
        return $http
   .get(BACKEND_URL + '/items/' + searchText)
   .then(function(data) {
     // Map the response object to the data object.
     return data;
     });
    } 
Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225
  • So what is wrong with this behavior? If user presses Enter - mean he did his choice and you don't need data from Server any more – Maxim Shoustin May 10 '17 at 08:18
  • The problem here is i did not received response for pending requests as they are cancelled and hence list is not updated as per entered text in input field – Amitesh A. Ghate May 10 '17 at 09:01
  • Just to add more details i have done debugging on Java web service end and it is processing request properly there, but somehow angularjs is cancelling pending requests at browser end – Amitesh A. Ghate May 10 '17 at 19:27

0 Answers0