0
我正在使用谷歌地圖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;
}
這是爲什麼不工作?
有你在控制檯中的任何錯誤? –