【发布时间】:2016-05-10 13:13:38
【问题描述】:
我正在使用角度谷歌地图 API。我想在按下按钮时清除搜索框输入字段。
HTML
<ui-gmap-search-box options="searchbox.options" template="searchbox.template" events="searchbox.events" position="searchbox.position" ng-model="searchModel.searchTerm"></ui-gmap-search-box>
<md-button class="md-icon-button searchbutton" ng-click="toggleSearch()" md-ink-ripple="false" aria-label="Custom Icon Button">
<md-icon md-svg-icon="images/search.svg"></md-icon>
</md-button>
JS
$scope.toggleSearch = function () {
var searchFieldInput = document.getElementById('pac-input')
if (searchFieldInput.classList.contains('searchactive')) {
searchFieldInput.classList.remove('searchactive')
} else {
searchFieldInput.classList.add('searchactive')
}
$scope.searchModel.searchTerm = null;
}
为什么这不起作用?
【问题讨论】:
-
控制台有错误吗?
标签: html angularjs google-maps angular-ngmodel angular-google-maps