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
Ung Dung AngularJSng-app = "ungdungAngularjs" ng-controller = "sinhvienController" >
Result:
Open the formtrongAngularjs.html page in the browser and see the results.
Follow tutorialspoint
Previous lesson: Modules in AngularJS
Next article: Include syntax in AngularJS
You should read it
May be interested
- Multilingual (i18n) in AngularJSangularjs provides multi-lingual functions (i18n) with 3 types of filters, currency, date and number. we just need to combine the js corresponding to the location depending on the country. by default it will attach to the location in the web browser.
- Expression in AngularJSexpression is used to bind application data to html tags. expression is written in {{expression}}. expression has a similar way of operating as the ng-bind directive.
- Controller component in AngularJSan angularjs application works primarily based on the controller component to control the flow of data in the application.
- MVC structure in AngularJSmodel view controller or mvc is a popular call, a software design model for web-based applications.
- Create the table in AngularJStable data is often repeated in natural order. in angularjs, ng-repeat directive can be used to draw tables easily. below is an example of how to use ng-repeat to create tables.
- Scope in AngularJSscope is a special javascript object with the role of linking controllers and views. scope contains information as model data. in the controller, model data can be accessed via the $ scope object.
- Form - Form in CSSforms - forms are an integral part of any kind of website. let's see how to build the display interface part of a basic form.
- HTML formthe form in html contains form elements - the element types that take input data such as filling in text fields, checkboxes, buttons, submit buttons ...
- How to create a Google Form form on Google Drivegoogle form on google drive form will help users create a table to collect information, comments, votes, or contact information of a group of subjects.
- Include syntax in AngularJShtml does not support embedding html web pages in html pages. to achieve this function, the following methods can be used: