Form in AngularJS
AngularJS complements the form of filling and validation features. You can use ng-click directive to handle the event by clicking on the button and using the flags $ dirty and $ invalid to make it effective. Use novalidate with the form declaration to disable the valicate feature of the form. The control section of the form uses an effective set of AngularJS events.
Events in AngularJS
AngularJS provides many events that can be linked to form controls of HTML. For example, ng-click usually attaches to a button. Here are the events supported by AngularJS.
- ng-click
- ng-dbl-click
- ng-mousedown
- ng-mouseup
- ng-mouseenter
- ng-mouseleave
- ng-mousemove
- ng-mouseover
- ng-keydown
- ng-keyup
- ng-keypress
- ng-change
Introducing ng-click directive in AngularJS
Reset the form's data using the ng-click directive of a button.
ten = "ho" type = "text" ng-model = "Ho" required > ten = "ten" type = "text" ng-model = "Ten" required > ten = "email" type = "email" ng-model = "email" required >
Validate data in AngularJS
Here are the variables used to track errors.
- $ dirty - Notice that the data is changed.
- $ invalid - Notice that the input is invalid.
- $ error - Accurate error message.
For example
Here is an example to illustrate the directives introduced above in the AngularJS application:
formtrongAngularjs.html
Vi du Form in AngularJS
You should read it
- Directive in AngularJS
- HTML DOM element in AngularJS
- What is AngularJS?
- View components in AngularJS
- Instructions for installing AngularJS
- Ajax in AngularJS
- The Filter in AngularJS
- The Service in AngularJS
- Expression in AngularJS
- The Module in AngularJS
- Create the table in AngularJS
- Create the first AngularJS application
Maybe you are interested
Google AI can predict long-term climate and weather trends in just minutes
Zoosk's Success Story: How Cutting-Edge Tech Elevated Online Dating
Why the habit of long-pressing the power button to turn off the computer can damage the system
4 Tips to Make Your Long-Distance Relationship Work During the Pandemic
See the bizarre, silly-string-like ocean creature that's blowing scientists' minds
New discovery of a long-standing vaccine may help fight SARS-CoV-2