include
类中的 exclude
和FormGroup
方法在RC5中已弃用,然后在RC6中删除。
那么,我们如何构建条件验证呢?我们以前用表单控件名称调用include / exclude。 addControl
和removeControl
是替代方案吗?
答案 0 :(得分:2)
在rc6(以及未来的版本)中,我使用 AbstractControl 启用和禁用方法解决了这个问题。
示例:
// 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();
希望它对你有所帮助。