Adding Angular Reactive Forms

You may wonder why we're adding Angular Forms, since we are adding just a single input field and not a form with multiple inputs. As a general rule of thumb, any time you add any input field, it should be wrapped in a <form> tag . The Forms module contains the FormControl that enables you to write the backing code behind the input field to respond to user inputs, and provide the appropriate data or the validation or message in response.

There are two types of Forms in Angular:

  • Template Driven: These forms are similar to what you may be familiar from AngularJS, where the form logic is mostly inside the HTML template. I'm personally not a fan of this approach, because it is harder to test these behaviors, and ...

Get Angular 6 for Enterprise-Ready Web Applications 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.