1

是否有任何替代方法来最小化代码行。

 this.addRoeForm.controls.supplierName.setValidators(Validators.required);
 this.addRoeForm.controls.fromCurrency.setValidators(Validators.required);
 this.addRoeForm.controls.toCurrency.setValidators(Validators.required);
 this.addRoeForm.controls.roe.setValidators(Validators.required);
4

1 回答 1

1
Object.keys(this.addRoeForm.controls).forEach(key => {
  this.addRoeForm.get(key).setValidators([Validators.required]);
});
于 2018-08-10T08:42:47.410 回答