I want to open a modal window and that the input that is in it be focused.
in the html file
<img id='searchIcon'
src="images/search.png"
class="icon iconCenter"
data-toggle="modal"
data-target="#myModal"
(click)='focusSearch();' />
<div id="myModal" class="modal fade modal-container" role="dialog">
<h3>SEARCH</h3>
<input id='inputSearch' type="text" autofocus>
</div>
With the autofocus attribute I got focus the first time that I open the modal view, but after I close and open the modal again doesn't do anything.(in firefox doesn't work at all)
in the ts file
focusSearch(){
document.getElementById("inputSearch").focus();
}
If someone can leave a quick demo I would appreciate it