正如你可以看到我正在使用setTimeout,如果我打算集中我的输入.如果我删除setTimeout焦点不起作用.
<div [hidden]="searchInputHidden">
<input (blur)="hideInput()" #term (keyup)="search(term.value)" type="text" class="inp_top" name="product_name" id="product_name" />
</div>
private showSearchInput(term) {
this.searchInputHidden = false;
setTimeout(function(){
term.focus();
}, 100);
}
Run Code Online (Sandbox Code Playgroud) angular ×1