我希望在Google地图自动填充事件触发时清除文本框值。我是AngularJS的新手,所以面临一点困难。有人可以帮忙吗?
HTML -
<input ng-model="deployText" id="search_execute" class="form-control" type="text" placeholder="Enter locations">
控制器功能中的JS代码 -
var autocomplete = new google.maps.places.Autocomplete($("#search_execute")[0], {types: ['(cities)']});
google.maps.event.addListener(autocomplete, 'place_changed', function() {
var place = autocomplete.getPlace();
angular.element(document.getElementById('execute_place')).append("<div style='float:left'>"+place.address_components[0].long_name+"</div>");
$scope.execute.push({latitude:place.geometry.location.lat(), longitude:place.geometry.location.lng()});
$scope.deployText = ""; //Here I want to clear the text
});
答案 0 :(得分:1)
您必须使用$scope.$apply()
作为非角度组件才能进行更改
$scope.deployText = ""; //Here I want to clear the text
$scope.$apply();