title: typeahead angular ui - cannot read property 'length' of undefined
body: <p>I am using Angular-ui Bootstrap for my application.
  I use the typeahead directive.</p>
  
  <p><strong>html</strong>:</p>
  
  <pre><code>&lt;input type="text" class="pass_code_input" ng-model="SuppPrefix" Typeahead="ddl_item.Text for ddl_item in getData($viewValue)"/&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>function AutoCompleteCtrl($scope,$http, AutoCompleteSrv) {
      $scope.getData = function (prefix) {
          AutoCompleteSrv.GetAutoComplete("Supplier", prefix).then(function (result) {
              var results_arr = [];
              angular.forEach(result.data, function (item) {
                  results_arr.push({ "Val": item.Val, "Text": item.Text });
              });
              return results_arr
          });  
      };
  };
  </code></pre>
  
  <p><strong>service:</strong></p>
  
  <pre><code>    function AutoCompleteSrv($http) {
      var _$http = $http;
      self = this;
      self.GetAutoComplete = function (DataType, Prefix) {
          var promise = _$http({
              method: "GET",
              url: 'api/AutoComplete',
              params: { 'DataType': DataType, 'Prefix': Prefix }
          }).success(function (data, status, headers, config) {
  
          }).error(function (data, status, headers, config) {
  
          });
          return promise;
      };
  };
  </code></pre>
  
  <p>I do recieve the data from server, but I can't display it on the screen. When I run debugger in chrome dev tools, I get the next error:</p>
  
  <pre><code>TypeError: Cannot read property 'length' of undefined
  at http://localhost:52145/js/libs/ui-bootstrap-tpls-0.11.0.min.js:13:12650
  at m.promise.then.u (http://localhost:52145/js/angular/angular.min.js:97:280)
  at m.promise.then.u (http://localhost:52145/js/angular/angular.min.js:97:280)
  at http://localhost:52145/js/angular/angular.min.js:98:417
  at h.$eval (http://localhost:52145/js/angular/angular.min.js:108:482)
  at h.$digest (http://localhost:52145/js/angular/angular.min.js:106:62)
  at h.$apply (http://localhost:52145/js/angular/angular.min.js:109:287)
  at HTMLInputElement.l (http://localhost:52145/js/angular/angular.min.js:133:191)
  at http://localhost:52145/js/angular/angular.min.js:31:32
  at q (http://localhost:52145/js/angular/angular.min.js:7:386)
  </code></pre>
  
  <p>I've searched for solution in multiple places, like <a href="https://stackoverflow.com/questions/19525184/angularui-bootstraps-typeahead-cant-read-length-property-of-undefined">that</a>, and also followed step by step the instructions in the bootstrap ui home page.
  What did I do wrong?</p>