Angular - What is the type of form for model selection or driven driven form?

when I use the Model-Driven form, for example:

@Component({
  selector: 'my-app',
  template: `
  <p>
    <label>First Name:</label>
    <input type="text"  [ngModel]="user.firstName" required>
  </p>
  `,
  providers: [myService]
})

and when I use the Driven pattern, for example:

 @Component({
      selector: 'my-app',
      template: `
      <p>
         <label>First Name:</label>
         <input type="text" formControlName="firstName">
      </p>
      `,
      providers: [myService]
    })

I think both things perform the same functionality. so i get a little confusion which is preferable when you start a new project?

+4
source share
1 answer

I think both things perform the same functionality. so i get a little confusion which is preferable when you start a new project?

At the moment, you have not fully studied the forms. There are certain things that are currently difficult or even impossible using form templates in Angular.

, , . . , Angular , .

, , - PR NgModelArray

T Driven Forms.

, .

+1

Source: https://habr.com/ru/post/1686850/


All Articles