Template-driven forms

As the name suggests, template-driven forms place the emphasis on developing a form within an HTML template and handling most of the logic for the form inputs, data validation, saving, and updating in-form directives placed within that template. The result is that very little form-related code is required in the component class that is associated with the form's template.

Template-driven forms make heavy use of the ngModel form directive. We will be discussing it in the next sections. It provides two-way data binding for form controls, which is a nice feature indeed. It allows us to write much less boilerplate code to implement a form. It also helps us to manage the state of the form (such as whether the form controls have changed and whether these changes have been saved). And, it also gives us the ability to easily construct messages that display if the validation requirements for a form control have not been met (for example, a required field not provided, email not in the right format, and so on).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.91.44