Template-driven forms

Template-driven forms

  • Are useful for adding a simple form to an app, such as an email list sign up form.
  • Template-driven forms are tied to template directives, and must provide custom validator directives that wrap validation functions.
  • Writing tests with template-driven forms requires a detailed knowledge of the change detection process and an understanding of how directives run on each cycle to ensure that elements are queried, tested, or changed at the correct time.
  • Template-driven forms rely on mutability with two-way data binding to update the data model in the component as changes are made in the template.
  • Template-driven forms focus on simple scenarios, are not as reusable, abstract away the low-level APIs, and provide asynchronous access to the form model.

Related concepts

Template-driven forms — Structure map

Clickable & Draggable!

Template-driven forms — Related pages: