How to manually set focus on mat-form-field in Angular 6 : <p>I am new to angular ,In my application I have a mat-dialog in which I have two forms namely Login and SignUp.</p>

<p>Once I open the dialog first time the auto focus is set on username field.problem is when I navigate to SignUp form on  button click that form's FIrst Name field not get auto focused ,the same way navigate from signup to login the username field is now not get auto focused.</p>

<p>I have tried to some stackoverflow solutions but nothing is resolved my issue.</p>

<p>popupScreen.component.html</p>

<pre><code>&lt;form class="login" *ngIf="isLoginHide"&gt;
    &lt;mat-form-field&gt;
        &lt;input matInput placeholder="username"&gt;
    &lt;/mat-form-field&gt;
    &lt;mat-form-field&gt;
        &lt;input matInput placeholder="password"&gt;
    &lt;/mat-form-field&gt;

    &lt;button mat-button color="primary"&gt;Login&lt;/button&gt;
    &lt;button mat-button (click)="hideLogin($event)" color="accent"&gt;SignUp&lt;/button&gt;
&lt;/form&gt;

&lt;form class="SignUp" *ngIf="isSignUpHide"&gt;
    &lt;mat-form-field&gt;
        &lt;input matInput placeholder="First Name"&gt;
    &lt;/mat-form-field&gt;
    &lt;mat-form-field&gt;
        &lt;input matInput placeholder="Last Name"&gt;
    &lt;/mat-form-field&gt;
    &lt;mat-form-field&gt;
        &lt;input matInput placeholder="username"&gt;
    &lt;/mat-form-field&gt;
    &lt;mat-form-field&gt;
        &lt;input matInput placeholder="password"&gt;
    &lt;/mat-form-field&gt;

    &lt;button mat-button (click)="hideSignUp($event)" color="primary"&gt;Login&lt;/button&gt;
    &lt;button mat-button color="accent"&gt;SignUp&lt;/button&gt;
&lt;/form&gt;
</code></pre>

<p>can anyone help me to solve this .</p>
