html forms Flashcards
What type of application is Angular?
Single-page application.
What are the two approaches to working with forms in Angular?
Template-driven and reactive.
What is the template-driven approach?
HTML form is created and Angular infers (deduces) the structure of the form.
It is used for more simple forms.
What is the Reactive Approach?
Structure is defined in code; form is setup in HTML and then both are manually connected; this approach
provides greater control.
What Module must be imported for Forms to work?
FormsModule.
What does the <form> tag tell Angular in template-driven approach?
Tells Angular to automatically create the template ONCE we register control of each field.
What is the reactive form approach?
The structure is defined in the TypeScript file (coded), Form set up done in HTML and then manually connected.
This type of approach provides greater control and is used for
larger and more complex forms
For reactive forms to work, what is needed?
Imports must be included from angular/forms.
What are validators?
A validator is a function that processes a FormControl or collection of controls and returns an error map or null. A null map means that validation has passed.
What is the syntax for a form import?
Import {FormGroup, FormControl} from ‘@angular/forms’;
How are validators imported?
import {…, Validators} from ‘@angular/forms’;