I made some minor modifications to the angular-ui typeahead example provided in http://angular-ui.github.io/bootstrap/
Here is the original code inside the controller.
$scope.getLocation = 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;
});
};
Here are the changes I made;
$scope.getLocation = function(val)
{
return $http.get('http://maps.googleapis.com/maps/api/geocode/json',
{
params:
{
address: val,
sensor: false
}
}).success(function(data, status, headers, config)
{
var addresses = [];
angular.forEach(data.results, function(item){
addresses.push(item.formatted_address);
});
return addresses;
});
};
What is wrong with my code? I did not get any error. The typeahead just did not work. I don't see any typeahead text as I type in the text inside the inputbox.
Thanks.