Skip to content

Instantly share code, notes, and snippets.

@gitSambhal
Created August 24, 2017 06:06
Show Gist options
  • Save gitSambhal/190f181ebbb11672f444ba9af526f8f6 to your computer and use it in GitHub Desktop.
Save gitSambhal/190f181ebbb11672f444ba9af526f8f6 to your computer and use it in GitHub Desktop.
It solves the issue with Google places autocomplete in IONIC which prevents clicking the result and getting the result in input field
<script>
// Assign Google autocomplete to pob
$scope.autocompletePOB = function(input){
console.log(input);
// This is a fix for Google Map Autocomplete unable to tap on result
$timeout(function() {
var predictionContainer = angular.element(document.getElementsByClassName('pac-container'));
predictionContainer.attr('data-tap-disabled', true);
predictionContainer.css('pointer-events', 'auto');
predictionContainer.on('click', function() {
// element.find('input')[0].blur();
document.getElementById('pob').blur();
});
}, 100);
var input = document.getElementById('pob');
var autocomplete = new google.maps.places.Autocomplete(input);
google.maps.event.addListener(autocomplete, 'place_changed', function() {
var place = autocomplete.getPlace();
input.value = place.name;
$scope.inquiry.pob = place.name
});
};
</script>
<input ng-autocomplete ng-model="inquiry.pob" type="text" name="pob" id="pob" required="required" >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment