fix(forms): fully support rebinding form group directive (#11051)
This commit is contained in:
@ -67,6 +67,12 @@ export function setUpControl(control: FormControl, dir: NgControl): void {
|
||||
dir.valueAccessor.registerOnTouched(() => control.markAsTouched());
|
||||
}
|
||||
|
||||
export function cleanUpControl(control: FormControl, dir: NgControl) {
|
||||
dir.valueAccessor.registerOnChange(() => _noControlError(dir));
|
||||
dir.valueAccessor.registerOnTouched(() => _noControlError(dir));
|
||||
if (control) control._clearChangeFns();
|
||||
}
|
||||
|
||||
export function setUpFormContainer(
|
||||
control: FormGroup | FormArray, dir: AbstractFormGroupDirective | FormArrayName) {
|
||||
if (isBlank(control)) _throwError(dir, 'Cannot find control with');
|
||||
@ -74,6 +80,10 @@ export function setUpFormContainer(
|
||||
control.asyncValidator = Validators.composeAsync([control.asyncValidator, dir.asyncValidator]);
|
||||
}
|
||||
|
||||
function _noControlError(dir: NgControl) {
|
||||
return _throwError(dir, 'There is no FormControl instance attached to form control element with');
|
||||
}
|
||||
|
||||
function _throwError(dir: AbstractControlDirective, message: string): void {
|
||||
let messageEnd: string;
|
||||
if (dir.path.length > 1) {
|
||||
|
Reference in New Issue
Block a user