我实际上遇到了同样的问题:
can't tap on item in google autocomplete list on mobile
简而言之:我点击了谷歌的自动完成建议,它在移动设备上不起作用,但在 PC 上工作得很好。
但是:我没有使用 cordova,只是使用 Nodejs 和响应能力来实现简单的 Angular 。我确实启用了 FastClick,但禁用并没有解决问题......
编辑:这是我的完整性代码: 标记( Jade ):
div
input(type="text" id="fulladdress" name="fulladdress" ng-model="location" class="form-control text-field" placeholder="Start typing...")
在 View 中:
form.row(ng-show="vm.isLogged" name="vm.form")
h2.order-title Delivery address
label(for="address") Address
google-places(location="vm.address")
js:
'use strict';
GooglePlacesDirective.$inject = ['$animate', 'Zipcode'];
function GooglePlacesDirective($animate, Zipcode) {
return {
scope: {location:'='},
restrict: 'E',
replace: true,
template: require('./google-places.html'),
link: link
};
function link(scope, element) {
scope.codeNotServed = false;
var options = {
componentRestrictions: {country: "us"}
};
var autocomplete = new google.maps.places.Autocomplete($("#fulladdress")[0], options);
google.maps.event.addListener(autocomplete, 'place_changed', function() {
scope.codeNotServed = false;
var place = autocomplete.getPlace();
var parts = place.address_components;
//do things with the parts; I've also tried doing nothing with the parts, but it didn't work either
});
}
}
module.exports = GooglePlacesDirective;
最佳答案
好的 - 不仅注释掉代码:
/*
if ('addEventListener' in document) {
console.log("Attaching FastClick event listener");
document.addEventListener('DOMContentLoaded', function() {
FastClick.attach(document.body);
}, false);
}
*/
还有库的实际加载:
<!--
<script src="/bower_components/fastclick/lib/fastclick.js"></script>
-->
看来问题已经解决了!
关于javascript - Angular : google autocomplete works on pc, 但在移动设备上点击不会加载建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39553113/