title: Angular Material autocomplete with $http call
body: <p>What i'm trying to do is an Angular Material autocomplete (<a href="https://material.angularjs.org/latest/api/directive/mdAutocomplete" rel="noreferrer" title="md-autocomplete">md-autocomplete</a>) with data dynamically retrieved from an AJAX call to my REST API. Unfortunately I get only indeterminate progress bar instead of autocomplete items as you can see below.</p>
  
  <h3>Result</h3>
  
  <p><a href="https://i.stack.imgur.com/yy5xj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yy5xj.png" alt="enter image description here"></a></p>
  
  <h3>Controller</h3>
  
  <pre><code>$scope.customersSelect = {};
  $scope.selectedItem = null;
  $scope.searchText = null;
  
  $scope.getCustomers = function (query) {
      selectsService.getCustomers(query).then(function (results) {
          $scope.customersSelect = results.data;
          console.log($scope.customersSelect);
      }, function(error) {
          alert(error.data.message);
      });
  }
  </code></pre>
  
  <h3>Service</h3>
  
  <pre><code>var selectsServiceFactory = {};
  
  _getCustomers = function (query) {
      return $http.get(serviceBase + 'api/selects/customers/' + query)
      .then(function(results) {
          return results;
      });
  }
  
  selectsServiceFactory.getCustomers = _getCustomers;
  
  return selectsServiceFactory;
  </code></pre>
  
  <h3>View</h3>
  
  <pre><code>&lt;md-autocomplete md-floating-label="Klient" 
              autocomplete="off" 
              flex="" 
              md-search-text-change="getCustomers(searchText)" 
              md-item-text="item" 
              md-items="item in customersSelect" 
              md-search-text="searchText" 
              md-selected-item="machine.customerId" 
              md-input-maxlength="100" 
              md-input-minlength="2" 
              md-input-name="machineOwner"&gt;
  &lt;md-item-template&gt;
      &lt;span md-highlight-text="searchText"&gt;{{item}}&lt;/span&gt;
  &lt;/md-item-template&gt; 
  </code></pre>
  
  <p></p>
  
  <p>I'm getting the data successfully from the API, because I can see it printed in the console.</p>