0
I have a registration form on Ionic 3, but I can’t validate the password with another ion input.
Register.html:
<ion-item class = "log-input">
<ion-label floating>Email</ion-label>
<ion-input type="text" #username></ion-input>
</ion-item>
<ion-item class = "log-input">
<ion-label floating>Senha</ion-label>
<ion-input type="password" #password></ion-input>
</ion-item>
<ion-item class = "log-input">
<ion-label floating>Confirmar</ion-label>
<ion-input type="password" #conf></ion-input>
</ion-item>
Register
Register.ts
import { Component,ViewChild} from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController} from 'ionic-angular';
import { AngularFireAuth } from 'angularfire2/auth';
@IonicPage()
@Component({
selector: 'page-register',
templateUrl: 'register.html',
})
export class RegisterPage {
@ViewChild('username') uname;
@ViewChild('password') password;
@ViewChild('password') conf;
constructor(private alertCtrl:AlertController,private fire:AngularFireAuth, public navCtrl: NavController, public navParams: NavParams) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad RegisterPage');
}
alert(message:string){
this.alertCtrl.create({
title: 'Info',
subTitle:message,
buttons: ['OK']
}).present();
}
registerUser(){
this.fire.auth.createUserWithEmailAndPassword(this.uname.value, this.password.value, this.conf.value)
.then(data=>{
console.log("Sucesso",data);
this.alert('Muito bem! Você está registrado.');
})
.catch(error =>{
console.log('Erro',error);
this.alert(error);
})
console.log("Registro com",this.uname.value , this.password.value);
}
}
Well when I call 'this.conf.value'' in the user create method, it gives an error, ''Expected 2 Arguments, but got 3''.
It is. @root if you want to validate if the password matches the confirmation, do a check before calling
createUserWithEmailAndPassword()
– Rosário Pereira Fernandes