我是angular的新手,在我的应用程序中有一个Mat-dialog,其中有两种形式,即Login和SignUp。
第一次打开对话框时,自动焦点设置在用户名字段上。问题是当我单击按钮导航到SignUp表单时,该表单的FIRST名字段没有自动聚焦,现在从注册导航到登录用户名字段的方法相同不能自动聚焦。
我已经尝试了一些stackoverflow解决方案,但没有任何解决方案解决我的问题。
popupScreen.component.html
<form class="login" *ngIf="isLoginHide">
<mat-form-field>
<input matInput placeholder="username">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="password">
</mat-form-field>
<button mat-button color="primary">Login</button>
<button mat-button (click)="hideLogin($event)" color="accent">SignUp</button>
</form>
<form class="SignUp" *ngIf="isSignUpHide">
<mat-form-field>
<input matInput placeholder="First Name">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Last Name">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="username">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="password">
</mat-form-field>
<button mat-button (click)="hideSignUp($event)" color="primary">Login</button>
<button mat-button color="accent">SignUp</button>
</form>
Run Code Online (Sandbox Code Playgroud)
谁能帮我解决这个问题。