其他分享
首页 > 其他分享> > form表单

form表单

作者:互联网

 遍历表单 

for (const [controlName, control] of Object.entries(this.journalBookCreateForm.controls)) {
            if (controlName === 'receiptType' || controlName === 'receiptAmount' ) {
          control.patchValue([]);
        }
      }

某个值不置空

for (const [controlName, control] of Object.entries(this.searchProductForm.controls)) {
      if (controlName === 'approvalStatus') {
        control.patchValue(3);
      } else {
        control.patchValue(null);
      }
    }

数据变化方法

this.journalBookCreateForm.get('paymentPlatformId').valueChanges.subscribe(value => {
      if (value != null) {
        this.getPaymentPlatformBalanceLoading = true;
        this.financeService.getAccountBalanceAmount(value).subscribe(mage => {
          if (mage.success) {
            this.paymentPlatformBalance = mage.data.amount;
          } else {
            this.nzMessage.error('获取账户余额错误!' + Mage.getMsgText(mage));
          }
          this.getPaymentPlatformBalanceLoading = false;
        });
      } else {
        this.paymentPlatformBalance = null;
        this.getPaymentPlatformBalanceLoading = false;
      }
    });

标签:control,form,patchValue,表单,else,controlName,null,mage
来源: https://blog.csdn.net/qq_36987708/article/details/118030534