角度.js - Google 自动完成事件触发时的清除文本框
Angular.js - Clear Text box when Google Autocomplete event fires?
我想在谷歌地图自动完成事件触发时清除文本框值。我是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
});
您必须对非角度组件使用 $scope.$apply()
才能进行更改
喜欢这个
$scope.deployText = ""; //Here I want to clear the text
$scope.$apply();
相关文章:
- 如何在OnPaste方法中清除文本区域
- 如何防止在进行选择时清除文本框
- 如何使用Javascript在按Backspace键时清除文本框
- 如何从文本区域输入中清除文本
- 想要清除文本框+聚焦文本框+阻止asp.net在同一按钮上回发
- javascript onclick radio清除文本框
- 清除文本区域会中断其他JS函数
- Javascript:如何清除文本框并恢复其值
- 如何重新启用禁用的下拉列表以及如何清除文本框数据
- 如何在删除/后退/清除文本框中的文本时清除 td 内容
- 按钮在 jsfiddle 中起作用,但不清除文本编辑器中的有序列表
- jQuery/Javascript:如何使用Javascript或jQuery清除文本框上的最近搜索
- 通过单击清除文本输入
- 清除文本框,但使用 Java 脚本给出错误
- 取消选中复选框时隐藏和清除文本框
- IE 不会清除文本区域值
- JavaScript 清除文本框 DOM 仅清除顶部框
- 清除文本框字段后再次加载选择框
- 清除文本框 脚本不起作用
- 角度.js - Google 自动完成事件触发时的清除文本框