function fetchResults (searchText) {
    var items = $scope.$parent.$eval(itemExpr),
        term  = searchText.toLowerCase(),
        isList = angular.isArray(items),
        isPromise = !!items.then; // Every promise should contain a `then` property

    if (isList) onResultsRetrieved(items);
    else if (isPromise) handleAsyncResults(items);

    function handleAsyncResults(items) {
      if (!items) return;

      items = $q.when(items);
      fetchesInProgress++;
      setLoading(true);

      $mdUtil.nextTick(function () {
          items
            .then(onResultsRetrieved)
            .finally(function(){
              if (--fetchesInProgress === 0) {
                setLoading(false);
              }
            });
      },true, $scope);
    }

    function onResultsRetrieved(matches) {
      cache[term] = matches;

      // Just cache the results if the request is now outdated.
      // The request becomes outdated, when the new searchText has changed during the result fetching.
      if ((searchText || '') !== ($scope.searchText || '')) {
        return;
      }

      handleResults(matches);
    }
  }
function fetchResults (searchText) {
    var items = $scope.$parent.$eval(itemExpr),
        term  = searchText.toLowerCase(),
        isList = angular.isArray(items),
        isPromise = !!items.then; // Every promise should contain a `then` property

    if (isList) onResultsRetrieved(items);
    else if (isPromise) handleAsyncResults(items);

    function handleAsyncResults(items) {
      if (!items) return;

      items = $q.when(items);
      fetchesInProgress++;
      setLoading(true);

      $mdUtil.nextTick(function () {
          items
            .then(onResultsRetrieved)
            .finally(function(){
              if (--fetchesInProgress === 0) {
                setLoading(false);
              }
            });
      },true, $scope);
    }

    function onResultsRetrieved(matches) {
      cache[term] = matches;

      // Just cache the results if the request is now outdated.
      // The request becomes outdated, when the new searchText has changed during the result fetching.
      if ((searchText || '') !== ($scope.searchText || '')) {
        return;
      }

      handleResults(matches);
    }
  }
function fetchResults ( searchText ) { var items = $scope . $parent . $eval ( itemExpr ) , term = searchText . toLowerCase ( ) , isList = angular . isArray ( items ) , isPromise = ! ! items . then ; // Every promise should contain a `then` property if ( isList ) onResultsRetrieved ( items ) ; else if ( isPromise ) handleAsyncResults ( items ) ; function handleAsyncResults ( items ) { if ( ! items ) return ; items = $q . when ( items ) ; fetchesInProgress ++ ; setLoading ( true ) ; $mdUtil . nextTick ( function ( ) { items . then ( onResultsRetrieved ) . finally ( function ( ) { if ( -- fetchesInProgress === 0 ) { setLoading ( false ) ; } } ) ; } , true , $scope ) ; } function onResultsRetrieved ( matches ) { cache [ term ] = matches ; // Just cache the results if the request is now outdated. // The request becomes outdated, when the new searchText has changed during the result fetching. if ( ( searchText || '' ) !== ( $scope . searchText || '' ) ) { return ; } handleResults ( matches ) ; } }
Fetches the results for the provided search text.
@param searchText
Fetches the results for the provided search text .
Fetch the results from the server