簡體   English   中英

搜索時禁用輸入字段,並將重點放在完成上

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

我有一個輸入字段,在鍵入內容時,我想搜索項目,同時在后台進行搜索時也要禁用文本字段,以便不再有字母可以在該輸入中鍵入,但是在完成搜索功能后,重點應該放在搜索上輸入字段,以便用戶可以開始輸入。

HTML:

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

零件:

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

在這里,我使用了禁用功能,但是在完成操作時,它並沒有關注輸入字段,並且在用戶手動單擊輸入字段之前也無法鍵入。

試試這個代碼。 這樣做有幫助。 HTML

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

零件

 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