1
我收到一個谷歌地圖的地方ID從休息API。然後我使用谷歌地圖API來獲取地方對象是這樣的:ng模型只更新輸入後點擊時使用谷歌地圖自動完成
var geocoder = new google.maps.Geocoder;
geocoder.geocode({
'placeId': data.city
}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
if (results[0]) {
$scope.place = results[0];
} else {
window.alert('No results found');
}
} else {
window.alert('Geocoder failed due to: ' + status);
}
});
我寫我正在使用的前端這樣它的作用域變量中的結果:
<label><span>Stadt</span><input type="text" g-places-autocomplete ng-model="place.formatted_address" name="city" class="f-trans"/></label>
我我正在使用github的kuhnza/angular-google-places-autocomplete作爲自動完成功能。不知怎的,現在我有問題了,當範圍變量被頂部的函數設置時,它不會更新輸入。只有當我在輸入字段內部單擊並且再次在輸入字段外部時,它纔會被更新,並且自動完成功能正在運行而沒有任何問題。它不需要使用我使用的「kuhnza/angular-google-places-autocomplete」標籤,因爲如果我刪除它,它仍然不起作用。