Correction pour soumettre le formulaire
avec la touche "Enter"
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<form [formGroup]="loginForm" (ngSubmit)="onLoginSubmit()" autocomplete="off" style="padding: 10px;">
|
||||
<form focusInvalidInput autocomplete="off" style="padding: 10px;"
|
||||
[formGroup]="loginForm" (ngSubmit)="onLoginSubmit()">
|
||||
<p>
|
||||
<mat-form-field>
|
||||
<mat-label>{{ 'LoginUser_Username' | translate }}</mat-label>
|
||||
|
||||
@@ -39,7 +39,7 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
||||
username: ['', [Validators.required, Validators.minLength(3)]],
|
||||
password: ['', [Validators.required]]
|
||||
},
|
||||
{ updateOn: 'blur' }
|
||||
{ updateOn: 'submit' }
|
||||
);
|
||||
|
||||
// get return url from route parameters or default to '/'
|
||||
@@ -54,21 +54,19 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
||||
onLoginSubmit() {
|
||||
this.submitted = true;
|
||||
|
||||
if (this.loginForm.invalid) {
|
||||
return;
|
||||
if (this.loginForm.valid) {
|
||||
this.loading = true;
|
||||
this.authenticationService.login(this.formCtrls.username.value, this.formCtrls.password.value)
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
data => {
|
||||
this.router.navigate([this.returnUrl]);
|
||||
},
|
||||
error => {
|
||||
this.error = error;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
this.authenticationService.login(this.formCtrls.username.value, this.formCtrls.password.value)
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
data => {
|
||||
this.router.navigate([this.returnUrl]);
|
||||
},
|
||||
error => {
|
||||
this.error = error;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user