简体   繁体   English

搜索时禁用输入字段,并将重点放在完成上

[英]Disable input field while searching and set focus on completion

I have an input field and on typing I want to search for items and also disable the text field while doing the search in background so that no more letters can type in that input, but on completion of search function, the focus should be the search input field so that user can start typing. 我有一个输入字段,在键入内容时,我想搜索项目,同时在后台进行搜索时也要禁用文本字段,以便不再有字母可以在该输入中键入,但是在完成搜索功能后,重点应该放在搜索上输入字段,以便用户可以开始输入。

Html: HTML:

<input [disabled]="(displayLoader > 0)" [ngModel]="''" (ngModelChange)="updateData($event)" class="form-control-search" placeholder="Search"/>

component: 零件:

updateData(event) {
   this.displayLoader = 1
   //search function
   //on completion
   this.displayLoader = 0; 
}

Here I used disabled, but on completion it is not focusing the input field and also cannot type until the user manually click the input field. 在这里,我使用了禁用功能,但是在完成操作时,它并没有关注输入字段,并且在用户手动单击输入字段之前也无法键入。

try this code. 试试这个代码。 does this help. 这样做有帮助。 html HTML

<input [disabled]="(displayLoader > 0)" [ngModel]="''" #focusable (ngModelChange)="updateData($event,focusable)" class="form-control-search" placeholder="Search"/>

component 零件

 updateData(event,el) {
       this.displayLoader = 1
       //search function
       //on completion
       this.displayLoader = 0; 
    el.focus();
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM