javascript - 如何重置 Angular 2中的输入值

标签 javascript jquery html angular

我想在按下回车、关闭或“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/

相关文章:

javascript - ajax 调用期间的回发

jquery - 鼠标移动时文本闪烁的问题?

javascript - 在单页应用程序中选择菜单时调用 Controller - angularJs

javascript - 当页面仍在等待远程图像时防止显示图像 URL

JavaScript map 文件在 Firefox 中不起作用

javascript - 与 JQuery 的 $(window) 有关的任何内容都不会在 IE 中触发

javascript - 通过javascript将图像转为卡通

html - 将 div 居中(水平和垂直),如果向下滚动则不要停留在中间

css - Chrome 打印网站,缺少布局选项

javascript - 使用javascript将Base64转换为图像文件