我想在按下回车、关闭或“x”按钮后重置搜索文本字段。根据我的代码,它会在关闭窗口后清除字符,但当我再次打开它时,它不会显示用户名列表直到我在搜索字段上按退格键。任何解决方案
代码:
export class child extends parent {
private findSubject = new Subject();
constructor() {
this.init();
this.findtream = this.findSubject.debounceTime(300);
}
}
<button type="button" (click)="close();findName.value=''" style="cursor: pointer; position: absolute; top: 18px;" [style.left.px]="functionalityActive === 0 ? 723 : 668"><span aria-hidden="true " style="font-size: 37px;">x</span></button>
<input type="text" #findName class="search-text" (keyup)="findSubject.next(findName.value)">
<button type="button" class="btn btn-danger event-buttons" id="create-button"(click)="close();findName.value=''">Close</button>
最佳答案
您可以尝试将 window.onload()
与 getElementById
结合使用,以在窗口重新加载时设置其值
关于javascript - 如何重置 Angular 2中的输入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60574250/