Created
August 24, 2017 06:06
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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