I have a FormControl in my Angular 8 app like this:
this.closingOrderFormGroup = this._fb.group({
final_price: new FormControl('', [ Validators.required ] ),
});
I tried to add/remove Validators.required dynamically based on some radio button check as follows:
radioChange( event ) {
const finalPriceControl: any = this.closingOrderFormGroup.get('final_price');
if ( event.value == 'completed' ) {
finalPriceControl.setValidators([Validators.required]);
}
else if ( event.value == 'rejected' ) {
finalPriceControl.setValidators(null);
}
}
But after set Validators null the FormControl "status" is still Invalid. How should I change the FormControl status?