Validation 执行验证后,数据不会保存在数据库上

Validation 执行验证后,数据不会保存在数据库上,validation,google-cloud-firestore,ionic4,Validation,Google Cloud Firestore,Ionic4,我的验证有问题,在实现saveProduct()函数后,我要存储的数据不会添加或更新到数据库中。另外,我共享了产品服务文件,因为有人说还必须在服务文件中传递'this.productForm.value'。但我不太清楚怎么做 代码如下:details.page.ts ngOnInit() { this.productForm = this.fb.group({ productName: new FormControl('', Validators.compose([ Validato

我的验证有问题,在实现saveProduct()函数后,我要存储的数据不会添加或更新到数据库中。另外,我共享了产品服务文件,因为有人说还必须在服务文件中传递'this.productForm.value'。但我不太清楚怎么做

代码如下:details.page.ts

ngOnInit() {
this.productForm = this.fb.group({
  productName: new FormControl('', Validators.compose([
    Validators.required,
  ])),
  productDecs: new FormControl('', Validators.compose([
    Validators.required,
  ])),
});
}

async saveProduct() {
await this.presentLoading();

this.product.userId = this.authService.getAuth().currentUser.uid;

if (this.productId) {
  try {
    console.log('product update');
    console.log(this.productForm.value);
    await this.productService.updateProduct(this.productId, this.productForm.value);
    await this.loading.dismiss();

    this.navCtrl.navigateBack('/vendor-tabs/home-vendor');
  } catch (error) {
    console.log('product dont update');
    this.presentToast('Error trying to save');
    this.loading.dismiss();
  }
} else {
  this.product.createdAt = new Date().getTime();

  try {
    console.log(this.productForm.value);
    console.log('product add');
    await this.productService.addProduct(this.productForm.value);
    await this.loading.dismiss();

    this.navCtrl.navigateBack('/vendor-tabs/home-vendor');
  } catch (error) {
    console.log('product dont add');
    this.presentToast('Error trying to save');
    this.loading.dismiss();
  }
}
}
下面是product.service.ts的代码

addProduct(product: Product) {
return this.productsCollection.add(product);
}

getProduct(id: string) {
return this.productsCollection.doc<Product>(id).valueChanges();
}

updateProduct(id: string, product: Product) {
return this.productsCollection.doc<Product>(id).update(product);
}

deleteProduct(id: string) {
return this.productsCollection.doc(id).delete();
}
addProduct(产品:产品){
返回此.productsCollection.add(产品);
}
getProduct(id:string){
返回此.productsCollection.doc(id).valueChanges();
}
updateProduct(id:string,product:product){
返回此.productsCollection.doc(id).update(产品);
}
deleteProduct(id:string){
返回此.productsCollection.doc(id).delete();
}

因此,根据您的代码,我看不到您的代码中有任何可观察到的已处理或错误。您能告诉我上面的代码将数据发送到firebase,或者您在控制台端收到任何错误吗?您能分享一下吗?我在控制台上没有收到错误。好的,那么在调用firebase
add()时处理可观察到的BCU呢
function它将返回`observer()`而我看不出您在代码中处理了这个问题?我想我没有处理这个问题。这是必须处理的吗?事实上不是,但它总是在捕获时抛出错误,或者运行时没有任何错误?