Binding a Form
Understand how to bind an Angular reactive form to a FormGroup instance and connect form inputs using formControlName. Explore how to link the form template with the form model to capture and log input values dynamically, ensuring proper form management without console errors.
We'll cover the following...
We’ve created a form group, but for some reason, our app is no longer working. This is because, from the moment we registered the ReactiveFormsModule, Angular will expect every <form> element to be bound to a form group. In our template, we don’t have any bindings. Angular will throw an error in the console as a result.
Form binding
We can bind a form to an instance of the FormGroup class by binding the formGroup property on the <form> element. Let’s update the template in the app.component.html file.