【问题标题】:How to reset input value in angular 2如何重置角度2中的输入值
【发布时间】:2020-03-07 14:42:17
【问题描述】:

我想在点击回车、关闭或“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>

【问题讨论】:

    标签: javascript jquery html angular


    【解决方案1】:

    你可以尝试window.onload()结合getElementById来设置它的值,当窗口重新加载时

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-31
      • 2020-11-14
      • 2017-10-28
      • 2016-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-22
      相关资源
      最近更新 更多