What is the purpose of the [(ngModel)] syntax in template-driven forms?

  • To create a two-way data binding for forms.
  • To define CSS styles for form elements.
  • To define form validation rules.
  • To set the form's action attribute for submission.
In template-driven forms in Angular, [(ngModel)] is used to create a two-way data binding between form controls in the template and the corresponding data model in the component class. This allows changes in the form controls to automatically update the model, and changes in the model to update the form controls. It's a key feature for working with form data.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *