Data binding with template-driven forms
Template-driven forms are one of two different ways of integrating forms with Angular. It is an approach that is not widely embraced by the Angular community for the reasons described previously. Nevertheless, it can be powerful in cases where we want to create small and simple forms for our Angular app. Τemplate-driven forms can stand out when used with the ngModel
directive to provide two-way data binding in our components.
We learned about data binding in Chapter 3, Component Interaction and Inter-Communication, and how we can use different types to read data from an HTML element or component and write data to it. In this case, binding is either one way or another, which is called one-way binding. We can combine both ways and create a two-way binding that can read and write data simultaneously. Template-driven forms provide the ngModel
directive, which we can use in our components to get this behavior. We can add template-driven forms...