Answers to other similar questions are talking about form scalability and unit testing.
Could you please give some examples of large scaled form that cannot be made by [(ngModel)]
with *ngIf
and *ngFor
?
About the unit testing, Angular official documentation gives samples of view-to-model and model-to-view testing cases. There ARE differences between two approaches.
But aren't those tests responsibility of @angular/forms
? Why should we do such tests in our own component? Shouldn't we trust Angular while using its official mature stable modules?
So please give evidences that Reactive Forms are really better than Template-Driven Forms, not just saying so.
Can you please state a case where reactive cover a scenario that can't be accomplished with template driven forms?
Can you please give a unit test example that is not the case and responsibility of Value Accessor?
Angular as an MVVM FE framework, you have a View(HTML template), you have a Model(JavaScript object represents the form), and you have a View-Model(two-way binding of [(ngModel)] and other directives beneath). Then there're the FormGroups, FormControls and FormArrays that managed to fulfill the same scalability as of JavaScript object?
TypeScript is already typed, now the typed forms?
<input [(ngModel)]="loginForm.email">
<input [(ngModel)]="loginForm.password">
export interface LoginForm {
email: string;
password: string;
}
export class MyComponent {
loginForm: LoginForm = {
email: '',
password: '',
}
// ...
}
Or double the complexity by a nullable
const email = new FormControl<string|null>('angularrox@gmail.com');
because its value will be null when you call reset email.reset()
.
... option affects the runtime behavior of your form when .reset() is called, and should be flipped with care ...
https://angular.io/guide/typed-forms#nullability
That'll just add burden to the developers.