2
即時特林驗證添加到FormContol動態(不是初始化),它不是工作....角2 FormGroup添加校驗動態
代碼:
this.formGroup.controls["firstName"].validator = Validators.Required;
有人做過嗎?
即時特林驗證添加到FormContol動態(不是初始化),它不是工作....角2 FormGroup添加校驗動態
代碼:
this.formGroup.controls["firstName"].validator = Validators.Required;
有人做過嗎?
//Try this, not verified, but should work
this.formGroup.controls["firstName"].setValidators(Validators.required);
對於多個驗證
this.formGroup.controls["firstName"].setValidators([Validators.required, Validators.minLength(2)]);
但這樣做將覆蓋在initialistaion
它的工作以及所提供的任何驗證!謝謝 :) – haya