In angularjs, form provides data-binding and validation of input controls.It provide form filling and form validation in angularjs. Input controls helps for user enter the data and a form is a collection of controls for the purpose of grouping related controls together.
Following are the input controls used in AngularJS forms:
- input elements
- select elements
- button elements
- textarea elements
Data-Binding
Input controls provides data-binding by using the ng-model directive. The ng-model directive is used to provide data binding.
Example
Let us take an example where ng-model directive binds the input controller to the rest of your application
You can also change the example in the following way:
You entered: {{firstname}}
AngularJS – Checkbox
In checkbox, it has two values either true or false. The ng-model directive is used for a checkbox.
Example
Checked
The ng-show attribute is set to true when the checkbox is checked.
AngularJS – Radio Buttons
Adding radio button into your angularjs application through ng-model directives.
Example
Orange
Apple
Mango
The ng-switch directive hides and shows HTML sections depending on the value of the radio buttons.
AngularJS – Select Box
The ng-model directive is used for a selectbox.
Example
Orange
Apple
Mango
The ng-switch directive hides and shows HTML sections depending on the value of the radio buttons.
AngularJS form example
Angular JS Forms AngularJS Sample Application