title: AngularJS typeahead giving [filter:notarray] error on Ajax GET query
body: <p>I have an AngularJS 1.4.7 typeahead:</p>
  
  <pre><code>&lt;input type="text" 
         class="form-control simpleinput"
         placeholder="keyword" 
         name="searchbarFormInput"
         id="searchbarFormInput" 
         ng-model="selected" 
         ng-click="selected=null"
         ng-enter="doBlur($event)"
         uib-typeahead="record.display_name for record in getRecords($viewValue) | filter:{ display_name : $viewValue }"
         typeahead-template-url="searchbar-result-template.html"
         typeahead-on-select="selectRecord($item)"
         typeahead-focus-on-select="false"
         typeahead-editable="false"
         autocomplete="off" /&gt; 
  </code></pre>
  
  <p>This typeahead's controller calls <code>getRecords(needle)</code> and filters on the provided <code>needle</code> value (<code>$viewValue</code>, or whatever value is in the <code>input</code> view):</p>
  
  <pre><code>$scope.getRecords = function(needle) {
      return $scope.testRecords;
  }
  </code></pre>
  
  <p>Here, <code>$scope.testRecords</code> is an array of test objects, e.g.:</p>
  
  <pre><code>$scope.testRecords = [ { "display_name" : "foo" } , { "display_name" : "bar" } ... ];
  </code></pre>
  
  <p>This works correctly. The typeahead will render a pulldown menu. The menu is filtered based on what I type into the <code>input</code> field.</p>
  
  <p>Now I want to source this array of records from a GET query:</p>
  
  <pre><code>$scope.getRecords = function(needle) {
      return $http.get('/search/by', {
          params: {
              'requestType' : 'searchByDisplayName',
              'pageSize' : 1000
          }
      }).then(function(res) {
          console.log(res.data.results);
          return res.data.results;
      });
  }
  </code></pre>
  
  <p>This is a GET request to a route that works when called directly (confirmed via, for example, <code>curl</code> or <code>wget</code>).</p>
  
  <p>Also, when I look at the browser console, <code>console.log(res.data.results)</code> shows the correct array of objects — the exact same objects that are in the array <code>$scope.testObjects</code>.</p>
  
  <p>However, I get no pulldown menu and I also get the following <code>[filter:notarray]</code>  error:</p>
  
  <pre><code>Error: [filter:notarray] http://errors.angularjs.org/1.4.7/filter/notarray?p0=%7B%22%24%24state%22%3A%7B%22status%22%3A0%7D%7D
  https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:6:421
  https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:149:197
  fn
  R@https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.14.3/ui-bootstrap-tpls.min.js:11:6694
  https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.14.3/ui-bootstrap-tpls.min.js:11:8633
  $$parseAndValidate@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:263:425
  $commitViewValue@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:263:284
  https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:265:279
  $eval@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:133:221
  $apply@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:133:456
  $$debounceViewValueCommit@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:265:249
  $setViewValue@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:264:507
  l@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:163:165
  c@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:35:221
  </code></pre>
  
  <p>This error repeats for as many letters as I enter into the <code>input</code> field.</p>
  
  <p>What am I doing wrong with the request, typeahead, or typeahead filter, and how can I fix this?</p>