0

我有一个父组件 AdsbyuserComponent,我需要使用 ag-grid 编辑或添加一行。我已经设法将信息发送到服务器,但是在关闭弹出表单时,我无法刷新表格。这是我的代码

AdsbyuserComponent

  update(ad :Ad) {
    let ngbModalOptions: NgbModalOptions = {
       backdrop : 'static',
       keyboard : false ,
   };
   const modalRef = this.modalService.open(EditAdComponent,ngbModalOptions);
   modalRef.componentInstance.ad = ad;
  }

编辑广告组件

onFormSubmitEdit() {
    this.activeModal.close();
    this.submitted = true;
    if (this.adForm.invalid) {
      return;
    }
    const ad = this.adForm.value;
    this.authService.getCurrentUser().subscribe((result) => {
      if (result) {
        ad.idowner = result.idUser;
        this.adService.updateAd(ad).subscribe(
          (res) => {
          },
          (err) => {
            console.log(err);
            alert(err.error);
          }
        );
      }
    });
  }
4

2 回答 2

0

我设法使用以下方法解决了这个问题:

this.router.navigateByUrl('/RefreshComponent', { skipLocationChange: true }).then(() => {
    this.router.navigate(['Your actualComponent']);
}); 
于 2020-05-14T21:29:43.310 回答
0

如果您想重新加载页面,请在提交结束时添加:window.location.reload();也许这会有所帮助

于 2020-05-14T21:18:10.437 回答