Change your validator signature from
return (formGroup: FormGroup)
to
return (controls: AbstractControl)
Then change the way you access the controls from
const from = formGroup.controls[fromName];
to
const from= controls.get(fromName);
Also change the way you report the errors back from
from.setErrors({ wrongDate: true });
to
return from.setErrors({ wrongDate: true }); // note the return statement.
One final change would be to change
newGroup = this.fb.group(
{
...
},
{
validator: CheckFromToDate(
node.type + '_' + node.objectId + '_dateFrom',
node.type + '_' + node.objectId + '_dateTo'
)
}
);
to
newGroup = this.fb.group(
{
...
},
{
validator: CheckFromToDate(
node.type + '_' + node.objectId + '_dateFrom',
node.type + '_' + node.objectId + '_dateTo'
)
} as AbstractControlOptions
);
Note the casting to AbstractControlOptions
and that should remove the deprecated warning.
You can refer the official documentation for a detailed explanation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…