ngAutocomplete
ngAutocomplete copied to clipboard
Doesn't have an option to use "submit" button
This should have an option to use a submit button which would do exactly the same as pressing enter.
If there's a way to simulate enter key, please let me know!
I ended up doing this in parent controller:
var autocompleteService = new google.maps.places.AutocompleteService();
$scope.getPlace = function () {
if ($scope.autocomplete)
autocompleteService.getPlacePredictions({
input: $scope.autocomplete,
types: ['geocode'],
componentRestrictions: { country: 'fi' }
}, callback);
};
function callback(predictions, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
alert(status);
return;
}
var googlePlacesService = new google.maps.places.PlacesService(document.getElementById("autocomplete"));
googlePlacesService.getDetails({
reference: predictions[0].reference
}, function (details, status) {
if (details) {
$scope.addressDetails = details;
$scope.centerMap();
}
});
}
centerMap() contains logic to set the formatted_address to my input field and centering the map.
+1
@henrihietala your trick works but I needed to add a $scope.$apply(); in the googlePlacesService.getDetails() callback function.
+1