How can you set default values for form controls in a template-driven form?

  • Use the defaultValue attribute.
  • Assign values directly in the template.
  • Set values programmatically in the component.
  • Use the ngDefaultControl directive.
In template-driven forms, default values for form controls are typically set programmatically in the component by initializing the corresponding form control variables with the desired default values. While you can assign values directly in the template, this doesn't allow for dynamic default values or interaction with the component logic. The other options mentioned are not common practices for setting default values in template-driven forms.
Add your answer
Loading...

Leave a comment

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