我有一个预先输入的输入。输入文本设置为在预先输入时选择的选项。但是,在我从预先输入的选项中选择一个选项后,我想清除此文本并在文本框中再次显示“占位符”值(因为我将所选值添加到selectMatch()
方法中的另一个 div。
<input id="searchTextBoxId" type="text"
ng-model="asyncSelected" placeholder="Search addresses..."
typeahead="address for address in getLocation($viewValue) | filter:$viewValue"
typeahead-loading="loadingLocations" class="form-control"
typeahead-on-select="selectMatch(asyncSelected)" typeahead-min-length="3"
typeahead-wait-ms="500">
我尝试使用其 Id 设置 Input 元素的文本值和占位符值,但这不起作用,例如:
// the input text was still the
$('#searchTextBoxId').attr('placeholder', 'HELLO');
选定的结果
// the input text was still the selected result
$('#searchTextBoxId').val('');
如何设置或重置文本值?