Angular 2 .focus() not working
<p>I want to open a modal window and that the input that is in it be focused.</p>

<p>in the html file</p>

<pre class="lang-html prettyprint-override"><code>&lt;img id='searchIcon' 
     src="images/search.png" 
     class="icon iconCenter" 
     data-toggle="modal" 
     data-target="#myModal" 
     (click)='focusSearch();' /&gt;

&lt;div id="myModal" class="modal fade modal-container" role="dialog"&gt;
    &lt;h3&gt;SEARCH&lt;/h3&gt;
    &lt;input id='inputSearch' type="text" autofocus&gt;
&lt;/div&gt;
</code></pre>

<p>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)</p>

<p>in the ts file</p>

<pre class="lang-ts prettyprint-override"><code>focusSearch(){
    document.getElementById("inputSearch").focus();
}
</code></pre>

<p>If someone can leave a quick demo I would appreciate it </p>