Model-Driven/Reactive forms

The Model-Driven approach was specifically added in Angular 2+ to address the known limitations of the Template-Driven forms; the forms implemented with this alternative method are known as Model-Driven forms or Reactive forms.

The main difference here is that (almost) nothing happens in the template, which acts as a mere reference of a TypeScript object--the form model--that gets instantiated and configured programmatically within the component class.

To better understand the overall concept, let's try to rewrite the previous form in a Model-Driven/Reactive way (the relevant parts are highlighted):

<form [formGroup]="form" (ngSubmit)="onSubmit()">    <input formControlName="title" required />    <span *ngIf="(form.get('title').touched ...

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.