Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在angular 2中重置输入值_Javascript_Jquery_Html_Angular - Fatal编程技术网

Javascript 如何在angular 2中重置输入值

Javascript 如何在angular 2中重置输入值,javascript,jquery,html,angular,Javascript,Jquery,Html,Angular,我想在按下enter、close或“x”按钮后重置搜索文本字段。根据我的代码,它会在关闭窗口后清除字符,但当我再次打开它时,它不会显示用户名列表,直到我在搜索字段上单击backspace。有什么解决办法吗 代码: 导出类子级扩展父级{ private findSubject=新主题(); 构造函数(){ this.init(); this.findtream=this.findSubject.debounceTime(300); } } x 接近 您可以尝试将window.onload()与ge

我想在按下enter、close或“x”按钮后重置搜索文本字段。根据我的代码,它会在关闭窗口后清除字符,但当我再次打开它时,它不会显示用户名列表,直到我在搜索字段上单击backspace。有什么解决办法吗

代码:

导出类子级扩展父级{
private findSubject=新主题();
构造函数(){
this.init();
this.findtream=this.findSubject.debounceTime(300);
}
}
x
接近

您可以尝试将
window.onload()
getElementById
组合,以在窗口重新加载时设置其值

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>