include and exclude methods in FormGroup class were deprecated in RC5 and then removed in RC6.
So, how are we supposed to build conditional validation? We used to call include/exclude with form control name. Are addControl and removeControl an alternative?
In rc6 (and future versions) I've solved this issue by using AbstractControl enable and disable methods.
Example:
// before (rc5):
//this.formGroup.exclude('controlName');
// after (rc6):
this.formGroup.get('controlName').disable();
// before (rc5):
this.formGroup.include('controlName');
// after (rc6):
this.formGroup.get('controlName').enable();
Hope it helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With