简体   繁体   中英

Can I know a way to submit data to Firebase without submitting the “Confirm-Password” field in Angular 8 Form?

Below code shows the reset function of my component.ts file. How can I enter data into the 'student' collection of firebase database without inserting confirm password field

ngOnInit() {
  this.resetForm();
}
resetForm(form?:NgForm){
if(form !=null)
form.reset();
this.user={
Email:'',
Password:'',
IndexNumber:'',
ConfirmPassword:''

onSubmit(form:NgForm){
let data=form.value;
 this.firestore.collection('student').add(data);
 this.resetForm(form);
}

If you have not added the confirm password document to your collection then you can simply remove the confirm password line from your code

ngOnInit() {
 this.resetForm();
}
resetForm(form ? : NgForm) {
  if (form != null)
   form.reset();
  this.user = {
    Email: '',
    Password: '',
    IndexNumber: '',
    ConfirmPassword: '' //Remove This

    onSubmit(form: NgForm) {
     let data = form.value;
     this.firestore.collection('student').add(data);
     this.resetForm(form);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM