【发布时间】:2019-02-08 02:46:13
【问题描述】:
我是 angular 新手,在我的应用程序中,我有一个 mat-dialog,其中有两种形式,即 Login 和 SignUp。
一旦我第一次打开对话框,自动焦点设置在用户名字段上。问题是当我导航到按钮上的注册表单时单击该表单的名字字段没有自动获得焦点,同样的方式从注册导航到登录用户名字段现在不会自动聚焦。
我尝试了一些 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>
谁能帮我解决这个问题。
【问题讨论】:
标签: angular typescript angular-material