Reputation: 5522
I'm working with a Reactive form and I have noticed in some tutorials they do the following:
HTML
.
.
<input type="text" formControlName="firstName" required>
.
.
TS
.
.
firstName: ['', Validators.required]
.
.
QUESTION:
Why do I need to specify "required" in the HTML if I just do it in the TS file it works fine?
Upvotes: 0
Views: 651
Reputation: 1950
Actually, Angular mention something about that here:
Caution: Use these HTML5 validation attributes in combination with the built-in validators provided by Angular's reactive forms. Using these in combination prevents errors when the expression is changed after the template has been checked.
Upvotes: 3