- The AngularJS provides many additional supports such as validation, data-binding to the HTML form.
- These are the input elements used in HTML form.
Syntax for text in AngularJS:
Syntax for radio button in AngularJS:
Syntax for select button in AngularJS:
Syntax for check box button in AngularJS:
Sample code for Form in AngularJS:
Code Explanation for Form in AngularJS:
- The ng-app specifies the root element (<div>) to define AngularJS application with controller “formCtrl”.
- The textbox is defined for getting name from user.
- The radio buttons are defined for getting Male gender from user.
- The radio buttons are defined for getting Female gender from user.
- The select box is defined for getting profession from user.
- The check box is defined for user accept the terms and conditions.
- The Reset is defined for Reset the form details.
- The information from the form is bind to the <h3> tag with ng-show attribute.
- The reset function is used to reset all values in the form.
Sample Output for Form in AngularJS:
- The form is displayed on page load.
- When user enter input to the form then that will be bind to the bottom of the form.
- Then User Click the reset button.
- All details are Resetted.