【问题标题】:Can I know a way to submit data to Firebase without submitting the "Confirm-Password" field in Angular 8 Form?我可以知道一种无需在 Angular 8 表单中提交“确认密码”字段即可向 Firebase 提交数据的方法吗?
【发布时间】:2019-10-22 10:04:28
【问题描述】:

以下代码显示了我的 component.ts 文件的重置功能。如何在不插入确认密码字段的情况下将数据输入到 firebase 数据库的“学生”集合中

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);
}

【问题讨论】:

    标签: javascript angular firebase google-cloud-firestore


    【解决方案1】:

    如果您尚未将确认密码文档添加到您的收藏中,那么您只需从代码中删除确认密码行

    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);
        }
    

    【讨论】:

      猜你喜欢
      • 2012-07-03
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-24
      • 1970-01-01
      相关资源
      最近更新 更多