Angularjs form detailed and sample code _ANGULARJS

Source: Internet
Author: User

ANGULARJS provides rich filling forms and validation. We can use Ng-click to handle ANGULARJS Click button events, and then use the $dirty and $invalid logo to do the verification method. Use the Novalidate form declaration to prohibit any browser-specific validation. form controls use a large number of corner activities. Let's take a quick look at the relevant events first.

Event

ANGULARJS provides multiple events that can be associated with an HTML control. For example, Ng-click is usually associated with a button. The following events are 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

Ng-click

Use the command to click a button to reset the data in the form.

<input name= "FirstName" type= "text" ng-model= "FirstName" required> "<input" name= "LastName" type= "
text" Ng-model= "LastName" required> <input name= "email" type= "email" ng-model= "
Email" required>
< Button ng-click= "reset ()" >Reset</button>
<script>
  function Studentcontroller ($scope) { 
   $scope. reset = function () {
     $scope. firstName = "Mahesh";
     $scope. LastName = "Parashar";
     $scope. email = "MaheshParashar@yiibai.com";
 }  
  $scope. Reset ();
</script>

Validating data

The following tracking error can be used.

$dirty-The specified value has been changed.

$invalid-The state of the value is invalid.

$error-point out the exact error.

Example

The following example shows all of the above instructions.

Testangularjs.html

 

Output

Open textangularjs.html in a Web browser. See the results below.

The above is the Angularjs form of knowledge collation, follow-up continue to supplement the relevant knowledge, thank you for your support of this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.