title: Limit typeahead results
body: <p>I'm using the angular-ui typeahead directive to connect to the Google Maps API and retrieve an array of addresses. Normally when I need to limit the amount of results visible I do something like:</p>
  
  <pre><code>&lt;input typeahead="eye for eye in array | filter:$viewValue | limitTo:10"&gt;
  </code></pre>
  
  <p>That works perfectly and the results are limited to 10. However, when I try to do the same thing with asynchronous results, it doesn't work. It will give more results than I specified in the <code>limitTo</code>. </p>
  
  <p>Am I doing something incorrectly below?</p>
  
  <p><a href="http://plnkr.co/edit/lwhA9sWNSGrMHhkndy7b?p=preview" rel="nofollow">Here is a plunker:</a> </p>
  
  <p>HTML:</p>
  
  <pre><code>  &lt;input ng-model="asyncSelected" typeahead="address for address in getLocation($viewValue) | limitTo:1" typeahead-loading="loadingLocations"&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>  $scope.getLocation = function(val) {
      return $http.get('http://maps.googleapis.com/maps/api/geocode/json', {
        params: {
          address: val
        }
      }).then(function(res){
        var addresses = [];
        angular.forEach(res.data.results, function(item){
          addresses.push(item.formatted_address);
        });
        return addresses;
      });
    };
  </code></pre>
  
  <p>Currently i'm doing the following to workaround, i'm just curious why a simple <code>limitTo</code> doesn't work.</p>
  
  <pre><code>$scope.getLocation = function(val) {
      return $http.get('http://maps.googleapis.com/maps/api/geocode/json', {
        params: {
          address: val
        }
      }).then(function(res){
        var addresses = [];
        var resultNumber = res.data.results.length &gt; 5 ? 5 : res.data.results.length;
        for(var i = 0; i &lt; resultNumber; i++){
          var obj = res.data.results[i];
          var addr = obj.formatted_address;
          addresses.push(addr);
        }
              return addresses;
      });
    };
  </code></pre>