Я использовал ngModel и все было хорошо.Теперь я использую форму Reactive для создания пользователя в Firebase.
Мой вопрос: как я могу получить доступ к значениям каждого поля, так как мне отмечается следующая ошибка: createUserWithEmailAndPassword failed: First argument" email "must be a valid string
компонент.html
<form [formGroup]="forma" (ngSubmit)="nuevoUsuario()" novalidate>
<mat-form-field appearance="outline">
<mat-label>E-mail</mat-label>
<input type="email" matInput placeholder="Ingresa tu E-mail" formControlName="email">
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Contraseña</mat-label>
<input type="password" matInput placeholder="Genera tu contraseña" formControlName="password">
</mat-form-field>
<button type="submit" class="btn btn-lg btn-primary btn-block mt-3" [disabled]="!forma.valid" >Crear cuenta <i class="fas fa-user-plus ml-2"></i></button>
</form>
component.ts
email: any;
password: string;
constructor(private fb: FormBuilder, public router: Router, public authService: FirebaseService) {
this.forma = fb.group ({
email: [ 'xxx@xxx.com', [Validators.required, Validators.email] ],
password: [ 'xxx', Validators.required ],
})
}
nuevoUsuario() {
firebase.auth().createUserWithEmailAndPassword(this.email, this.password)
.then(userData => {
userData.sendEmailVerification();
this.router.navigate(['/ingresar']);
console.log(userData)
})
.catch(err => {
console.log(err)
});
}