Chapter 3. Building Template-Driven and Reactive Forms

This chapter will cover the following recipes:

  • Implementing simple two-way data binding with ngModel
  • Implementing basic field validation with a FormControl
  • Bundling FormControls with a FormGroup
  • Bundling FormControls with a FormArray
  • Implementing basic forms with ngForm
  • Implementing basic forms with FormBuilder and formControlName
  • Creating and using a custom validator
  • Creating and using a custom asynchronous validator with Promises

Introduction

Forms are important elemental constructs for nearly every web application, and they have been reimagined for the better in Angular 2. Angular 1 forms were very useful, but they were totally dependent on the conventions of ngModel. Angular 2's newfound conventions ...

Get Angular 2 Cookbook 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.