When setting up a control with required validator (eg:
new FormControl('', Validators.Required) ), the required directive
[required] does not have effect.
I would expect the changes in the value of the "required" directive would be aligned with the control validators.
I found that issue in angular 12 but seems to be also happening in angular 14.2
In the minimal reproduction we can see three controls.
First one with initial required validator plus a custom
isRequired directive which acts as I would expect.
Second one without initial required validator plus
required directive which acts as I would expect.
Third one with initial required validator plus
required directive which required gets miss aligned.
As explained in the Documentation: https://angular.io/guide/form-validation#validating-input-in-reactive-forms
In a reactive form, the source of truth is the component class. Instead of adding validators through attributes in the template, you add validator functions directly to the form control model in the component class.
If you need to change the required attribute, update the control's Validators on the component side.
|Issue Title||Created Date||Updated Date|