2
\$\begingroup\$

I am developing this angular app and it has big forms with 100 + fields. I was thinking about using [(ngModel)] without reactive forms, so that it's easier to do validations and I only have to provide the same JSON to the web service endpoint. Is this a right approach?

Reactive forms

export class ProfileEditorComponent {
  profileForm = new FormGroup({
    firstName: new FormControl(''),
    lastName: new FormControl(''),
  });
}

<input type="text" formControlName="firstName">

Alternative

    export class ProfileEditorComponent {
     profileForm = {
       firstName:""
     }
    }

<input type="text" [(ngModel)]="profileForm.firstName">

My idea was to handle all the validations and everything manually.

| improve this question | | | | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.