title: Bootstrap typeahead doesnt work when call async task from service in angularJS
body: <p>I try to play with bootstrap typeahead and angular. When current method was in controller - all worked fine:</p>
  
  <pre><code>$scope.getLocation_work = function(val) {
      return $http.get('http://maps.googleapis.com/maps/api/geocode/json', {
        params: {
          address: val,
          sensor: false
        }
      }).then(function(res){
        var addresses = [];
        angular.forEach(res.data.results, function(item){
          addresses.push(item.formatted_address);
        });
        return addresses;
      });
    };
  </code></pre>
  
  <p>When I tried to put the logic into service, I started get errors:</p>
  
  <pre><code>ypeError: Cannot read property 'length' of undefined
  </code></pre>
  
  <p><strong>in controller</strong></p>
  
  <pre><code>$scope.getLocation = function(val) {
              UtilsFactory.getLocation(val).then(function(res){
                  var addresses = [];
                  angular.forEach(res, function(item){
                      addresses.push(item.formatted_address);
                  });
                  return addresses;
              });
          };
  </code></pre>
  
  <p><strong>Service</strong></p>
  
  <pre><code>app.factory('UtilsFactory', ['$http', '$q', function($http, $q) {
                  return {
                      getLocation : function(val) {
                            var deferred = $q.defer();
                            var response = $http.get('http://maps.googleapis.com/maps/api/geocode/json', {
                  params: {
                      address: val,
                      sensor: false
                  }
              });
  
               deferred.resolve(response);
                 return deferred.promise;
                  }      
         }
    }
  ]);
  </code></pre>
  
  <p>Do I miss something?</p>
  
  <p>Here is Demo in <a href="http://plnkr.co/edit/VZ69JlKhzbWvm6I68lQA?p=preview" rel="nofollow">Plunker</a></p>
  
  <p>Thanks,</p>