AI Hints
Home›Angular Tutorial›Forms in Angular, Template-Driven Forms and Reactive Forms
Angular · Lesson 82 of 120

Forms in Angular

Collect input.

⏱ 2 min read▶ Video at 1:38:14🎓 Free
Watch this lesson in the Angular courseWatch on YouTube ↗Full Angular course

Shops need forms. Sign up, log in, the delivery address, and checkout. Angular helps us read what users type, and check it.

  • Sign up, log in
  • Delivery, checkout
  • Read and check input

What a form tracks

For every field, Angular tracks its value, and whether it's valid. It also tracks if the user has touched the field, and if they've changed it. We use these to show errors at the right moment, and to stop bad data being sent.

keyvalue
valuewhat was typed
valid / invaliddoes it pass the rules?
touchedhas the user left it?
dirtyhas the user changed it?

Three ways to build forms

Template driven forms are set up in the template, with ng model. Reactive forms are built in the class, with form controls. And signal forms, the newest, build a form from a signal. We'll learn all three, starting with the simplest.

ApproachBuilt withGood for
Template-drivenngModel in the templatesmall, simple forms
ReactiveFormControl in the classbigger forms, tests
Signal formsform(signal) in the classnew signal-based apps

Summary

Angular forms track each field's value, validity, and state. There are three ways to build them. Next, template driven forms.

Key takeaways
  • value, valid
  • touched, dirty
  • Three approaches
Next up: Template-Driven Forms — ngModel