Я бы лучше использовал
FormBuilder и
ReactiveForms<form [formGroup]="loginForm" (ngSubmit)="onSubmitLoginForm()" novalidate>
<input formControlName="userLogin" #userLoginInput type="email">
<input formControlName="userPassword" type="password">
</form>
// import
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
export class AuthorizationFormComponent {
public loginForm : FormGroup;
@ViewChild('userLoginInput') userLoginInput;
constructor(
private _builder : FormBuilder,
) {
// Form builder and validation configuration
this.loginForm = this._builder.group({
userLogin: [ '', [ Validators.required ] ],
userPassword: [ '', [ Validators.required ] ],
});
}
onSubmitLoginForm () {
this.userLoginInput.nativeElement.focus()
}
}