SoFunction
Updated on 2025-04-07

How to use angularJs

In this update, the blogger will share with you some of the common attributes and methods of AngularJs. AngularJS was developed by Google employee Miško Hevery since 2009. This is a very good idea, the project is currently officially supported by Google, and there is a full-time development team that continues to develop and maintain this library. AngularJS is a JavaScript framework. It is a library written in JavaScript. Therefore, it will be easier for friends who have a certain JavaScript foundation to understand. Some of the usages can also refer to the usage methods of Javascript.

1. Instructions and expressions for getting started with AngularJS

AngularJS extends HTML through directives and binds data to HTML through expressions.

【Common AngularJS Directives】

1. ng-app: Declare the area under Angular. Generally written on body or html, in principle, there is only one page;

<body ng-app=""></body>

2. ng-model: Bind element values ​​(such as the value of the input field) into the application variable.

<input type="text" ng-model="name"/>

3. ng-bind: binds the data in application variables to HTML view. The expression {{ }} can be replaced;

<div ng-bind="name"></div>
<div>{{name}}</div>

4. ng-init: Initialize variables in AngularJS application.

<body ng-app="" ng-init="name=123">

5. Expression: {{}} bind expressions, which can contain literals, operators and variables. But the expression will see {{}} when the web page is loaded, so it can be usedng-bind=""Alternative

{{ 5 +""+ 5 + ',Angular'}}

【Basic Concept】

1. Directive: In AngularJS, it provides functions by extending HTML attributes. Therefore, the new attribute at the beginning of ng- is called a command

&lt;!DOCTYPE html&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;AngularJSgetting Started&lt;/title&gt;
 &lt;/head&gt;
&lt;body ng-app="" ng-init="name=123"&gt;

  &lt;input type="text"  ng-model="name"/&gt;
  &lt;div  ng-bind="name+',Angular'"&gt;{{name}}&lt;/div&gt;

  &lt;input type="text"  ng-model="name"/&gt;

  &lt;p&gt;My first expression: {{ 5 +""+ 5 + ',Angular'}}&lt;/p&gt;

 &lt;/body&gt;

 &lt;script src="libs/jquery-3.1."&gt;&lt;/script&gt;
 &lt;script src="libs/"&gt;&lt;/script&gt;

 &lt;script type="text/javascript"&gt;
//  var input1 = ("input");
//  var div = ("div");
//  
//   = function(){
//    = ;
//  }

//  $("#input").keyup(function(){
//   $("#div").html($("input").val());
//  });
 &lt;/script&gt;
&lt;/html&gt;

2. MVC and scope in AngularJS

[MVC three-layer architecture]

1、Model:The part of the application that is used to process data. (Save or modify data to databases, variables, etc.). Model in AngularJS specifically refers to: data

View (view):The page seen by the user to display the data;

Controller:The part of the application that handles user interaction. Responsible for reading data from the view, controlling user input, and sending data to the model.

2、How it works: The user issues a request from the view layer. After the controller receives the request, it forwards it to the corresponding model processing. After the model processing is completed, the result is returned to the controller and feedback it to the user at the view layer.

Mainly used for CRUD applications, not suitable for game development and DOM operations

To create an Angular module, that is, the part bound to ng-app, you need to pass two parameters:

① The module name, that is, the name that needs to be bound by ng-app. ng-app="myApp"

② Array: The module name that needs to be injected, does not need to be nullable.

var app = ("myApp",[]);

On the Angular module, creating a controller controller requires passing two parameters

① Controller name, that is, the name that ng-controller needs to be bound. ng-controller="myCtrl"

② Controller constructor: The constructor can pass in multiple parameters, including $scope/$rootScope and various built-in objects in the system;

[Scope in AngularJS]

$scope:Local scope, declared properties and methods on $scope, can only be used in the current controller;

$rootScope:Root scope, declared properties and methods on $rootScope, can be used in any area contained in ng-app (regardless of the same Controller or in the Controller included scope).

>>> If the variables are not declared using $scope, but the variables bound directly using ng-model in html are scoped:

1. If the ng-model is in a ng-controller, this variable will be bound to the $scope of the current controller by default;

2. If the ng-model does not have an ng-controller clock, this variable will be bound to $rootScope;

("myCtrl",function($scope,$rootScope){
//$ = "name1";
$ = 14;
$ = {
name:"H51701",
num:"33"
};
});
("myCtrl1",function(){
});

3. Angular filter

In AngularJS, filters can be added to expressions and directives using a pipe character (|).

>>> System built-in filter:

currency Format numbers into currency format.

filter Select a subset from the array item.

lowercase The formatted string is lowercase.

orderBy Arrange arrays according to a certain expression.

uppercase The formatted string is capitalized.

&lt;!DOCTYPE html&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;link rel="stylesheet" href="css/" rel="external nofollow" /&gt;
 &lt;/head&gt;

 &lt;body ng-app="app" ng-controller="ctrl"&gt;

  &lt;p&gt;{{"aBcDeF"|uppercase}}&lt;/p&gt;
  &lt;p&gt;{{"aBcDeF"|lowercase}}&lt;/p&gt;
  &lt;p&gt;{{123456|currency}}&lt;/p&gt;
  &lt;form class="form-horizontal"&gt;

  &lt;/form&gt;
  &lt;div class="form-group"&gt;
   &lt;label&gt;Please enter filter information:&lt;/label&gt;
   &lt;input type="text" ng-model="search" /&gt;
  &lt;/div&gt;

  &lt;table class="table table-bordered"&gt;
   &lt;thead&gt;
    &lt;tr&gt;
     &lt;th&gt;Name&lt;/th&gt;
     &lt;th&gt;age&lt;/th&gt;
     &lt;th&gt;score&lt;/th&gt;
    &lt;/tr&gt;
   &lt;/thead&gt;
   &lt;tr ng-repeat="item in classes| filter:search | orderBy:'score'"&gt;
    &lt;td&gt;{{}}&lt;/td&gt;
    &lt;td&gt;{{}}&lt;/td&gt;
    &lt;td&gt;{{}}&lt;/td&gt;
   &lt;/tr&gt;
  &lt;/table&gt;

  &lt;p&gt;{{"123456"|reverse}}&lt;/p&gt;

 &lt;/body&gt;
 &lt;script src="libs/"&gt;&lt;/script&gt;
 &lt;script&gt;

  ("app",[])
  .controller("ctrl",function($scope){
   $ = [
    {name:"Zhang Er",age:"12",score:"88"},
    {name:"Zhang San",age:"12",score:"88"},
    {name:"Li Si",age:"15",score:"78"},
    {name:"Li Wu",age:"15",score:"78"},
    {name:"Wang Mazi",age:"18",score:"98"},
    {name:"Wang Ermazi",age:"18",score:"98"}
   ];

  })
  /*
    * Custom filters
    */
  .filter('reverse', function() {

   return function(text) {
    if(!(text)){
     return "What you entered is not a string";
    }else{
     return ("").reverse().join("");
    }

   }
  })
 &lt;/script&gt;
&lt;/html&gt;

4. Angular Service

【Service Service】

1. Built-in service:

>>> Using built-in services must be injected into the controller through the parameters of the function! ! ! !

$location: Returns the URL address of the current page;

$http: Server requests data, similar to AJax;

$timeout: Corresponds to the JS function.

$interval: Corresponding to the JS function.

&lt;!DOCTYPE html&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;&lt;/title&gt;
 &lt;/head&gt;
 &lt;body ng-app="app" ng-controller="ctrl"&gt;
  &lt;pre &gt;{{local}}&lt;/pre&gt;
  &lt;p ng-bind="myHeader"&gt;&lt;/p&gt;
  &lt;p ng-bind="num"&gt;&lt;/p&gt;
  &lt;p &gt;{{gongneng}}&lt;/p&gt;
  &lt;p&gt;Will255Turn to16Pricing:{{hexafy}}&lt;/p&gt;
  &lt;p&gt;{{123|filt}}&lt;/p&gt;

  &lt;p&gt;{{123|filt1}}&lt;/p&gt;

 &lt;/body&gt;
 &lt;script type="text/javascript" src="libs/" &gt;&lt;/script&gt;
 &lt;script type="text/javascript"&gt;

  ("app",[])
  .controller("ctrl",function ($scope,$location,$timeout,$interval,$hexafy) {
   $=$();
    $ = "Hello World!";
   $timeout(function () {
    $ = "How are you today?";
   }, 2000);
   $=0;
   $interval(function () {
    $++;
   },1000);

   $=$hexafy.$$gongneng;
   $=$(255);
  })
  /*Custom Service*/
  .service('$hexafy', function() {
   this.$$gongneng = "Convert the transferred number to hexadecimal";
    = function (x) {
    return (16);
   }
  })
  .filter("filt",function(){
   return function(x){
    return (16);
   }
  })
  /*In the filter, call custom service*/
  .filter("filt1",function($hexafy){
   return function(x){
    return $(x);
   }
  })
 &lt;/script&gt;
&lt;/html&gt;

【Custom Service Factory】

factory is a function that returns a value. Usually we use factory function to calculate or return a value. (There is not much difference between factory and service)

&lt;!DOCTYPE html&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;link rel="stylesheet" href="libs/" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" /&gt;
 &lt;/head&gt;

 &lt;body ng-app="app" ng-controller="ctrl"&gt;
  &lt;p&gt;
   [Function]&lt;br/&gt;
   {{gongneng}}
  &lt;/p&gt;
  &lt;p&gt;
   255Convert to16Priority as:{{num}}
  &lt;/p&gt;
 &lt;/body&gt;
 &lt;script src="libs/"&gt;&lt;/script&gt;
 &lt;script&gt;

  ("app",[])
  .config()
  .controller("ctrl",function($scope,hexafy){
   $ = ;
   $ = (255);
  })
  .factory('hexafy',function(){
   var obj = {
    gongneng : "Convert the transferred number to hexadecimal",
    myFunc:function(x){
     return (16);
    }
   };
   return obj;
  })
 &lt;/script&gt;
&lt;/html&gt;

【Custom service provider】

1. In AngularJS, Service and factory are all implemented based on providers.

2. In the provider, the $get() method is used to return value/service/factory. ;

3. Provider is the only one among the three custom services that can be written into the config configuration stage.

If the service must be executed during the configuration phase, then the provider must be used. Otherwise, Service or factory is generally used

&lt;!DOCTYPE html&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;link rel="stylesheet" href="libs/" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" /&gt;
 &lt;/head&gt;

 &lt;body ng-app="app" ng-controller="ctrl"&gt;
  &lt;p&gt;
   [Function]&lt;br/&gt;
   {{gongneng}}
  &lt;/p&gt;
  &lt;p&gt;
   255Convert to16Priority as:{{num}}
  &lt;/p&gt;
 &lt;/body&gt;
 &lt;script src="libs/"&gt;&lt;/script&gt;
 &lt;script&gt;

  ("app",[])
  /*Declare the procide service during the configuration phase!  */

  .controller("ctrl",function($scope,hexafy){
   $ = ;
   $ = (255);
  })

  /*Define a provider service*/
  .provider('hexafy',function(){
// = "Convert the transferred number to hexadecimal";   this.$get = function(){
    var obj = {
     gongneng : "Convert the transferred number to hexadecimal",
     myFunc : function(x){
      return (16);
     }
    }
    return obj;
   }
  })
 &lt;/script&gt;
&lt;/html&gt;

5. $http in Angular

$http is a core service in AngularJS that reads data from remote servers.

&lt;!DOCTYPE html&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;link rel="stylesheet" href="libs/" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" /&gt;
 &lt;/head&gt;

 &lt;body ng-app="app" ng-controller="ctrl"&gt;
  &lt;!--&lt;pre&gt;
   {{data}}
  &lt;/pre&gt;--&gt;
  &lt;div class="container" style="margin-top: 50px;"&gt;
  &lt;div class="panel panel-primary" &gt;
   &lt;div class="panel-heading"&gt;
    &lt;div class="panel-title" style="text-align: center;"&gt;H5-1701Class information table&lt;/div&gt;
   &lt;/div&gt;
   &lt;div class="panel-body"&gt;
    &lt;table class="table table-bordered"&gt;
     &lt;thead&gt;
      &lt;tr&gt;
       &lt;th&gt;Name&lt;/th&gt;
       &lt;th&gt;age&lt;/th&gt;
       &lt;th&gt;Hobby&lt;/th&gt;
       &lt;th&gt;Chinese scores&lt;/th&gt;
       &lt;th&gt;Mathematics Score&lt;/th&gt;
       &lt;th&gt;Total points&lt;/th&gt;
      &lt;/tr&gt;
     &lt;/thead&gt;
     &lt;tr ng-repeat="item in data | orderBy:' + '"&gt;
      &lt;td ng-bind=""&gt;&lt;/td&gt;
      &lt;td ng-bind=""&gt;&lt;/td&gt;
      &lt;td ng-bind=""&gt;
      &lt;!--&lt;span ng-repeat="a in "&gt;{{a}}&lt;/span&gt;--&gt;
      &lt;/td&gt;
      &lt;td ng-bind=""&gt;&lt;/td&gt;
      &lt;td ng-bind=""&gt;&lt;/td&gt;
      &lt;td ng-bind=" + "&gt;&lt;/td&gt;
     &lt;/tr&gt;
    &lt;/table&gt;
   &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;

 &lt;/body&gt;
 &lt;script src="libs/"&gt;&lt;/script&gt;
 &lt;script&gt;

  ("app",[])
  .controller("ctrl",function($scope,$http){

   $('',{/*Passed parameter object*/})
   .then(function(res){
    $ = ;//data Extract the required data from the returned information.  For JSON objects (array)   });

  })
 &lt;/script&gt;
&lt;/html&gt;

6. Select in Angular

Use arrays as data source.

Where x represents each item in the array.

By default, x will be bound directly to the option value.

The content displayed by option has the previous x for...

<select ng-model="name" ng-options=" for x in sites">
  </select>

Use objects as data source.

Where (x,y) represents a key-value pair, x is a key, and y is a value.

By default, the value y will be bound to the value of option.

The content displayed by option has the previous x for...

&lt;!DOCTYPE html&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;link rel="stylesheet" href="libs/" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" /&gt;
  &lt;style type="text/css"&gt;
   *{
    margin: 10px;
   }
  &lt;/style&gt;
 &lt;/head&gt;

 &lt;body ng-app="app" ng-controller="ctrl"&gt;

  &lt;select ng-model="name" ng-options="x for (x, y) in sites"&gt;
  &lt;/select&gt;

  &lt;div class="alert alert-info" style="width: 300px;"&gt;
   You chose:{{name}}
  &lt;/div&gt;

  &lt;table class="table table-bordered"&gt;
   &lt;tr&gt;
    &lt;th&gt;Serial number&lt;/th&gt;
    &lt;th&gt;Name&lt;/th&gt;
   &lt;/tr&gt;
   &lt;tr ng-repeat="item in options"&gt;
    &lt;td&gt;{{$index +1}}&lt;/td&gt;&lt;!--$index Indicates the index of traversal,from0start--&gt;
    &lt;td&gt;{{item}}&lt;/td&gt;
   &lt;/tr&gt;
  &lt;/table&gt;

 &lt;/body&gt;
 &lt;script src="libs/"&gt;&lt;/script&gt;
 &lt;script&gt;

  ("app",[])
  .controller("ctrl",function($scope){
   $ = ["Zhang San","Li Si","Wang Ermazi","Jie Xiaorui"];

   $ = {
    site01 : "Google",
    site02 : "Runoob",
    site03 : "Taobao"
   };

  })
 &lt;/script&gt;
&lt;/html&gt;

7. DOM and Events in Angular

ng-disabled="true/false" The control is disabled when true is passed. Passing in false is, enable;

ng-show is hidden by default. It is displayed when true is passed;

ng-hide default display Passed in true is hidden;

ng-click defines click events in AngularJS.

Only properties and methods bound in Angular scope can be triggered.

&lt;!DOCTYPE html&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;link rel="stylesheet" href="libs/" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" /&gt;
  &lt;style type="text/css"&gt;
   *{
    margin: 10px;
   }
  &lt;/style&gt;
 &lt;/head&gt;

 &lt;body ng-app="app" ng-controller="ctrl"&gt;

   &lt;input type="checkbox" ng-model="mySwitch"&gt;Do you agree that I am a handsome guy!
  &lt;/label&gt;

  &lt;button ng-disabled="!mySwitch" class="btn btn-primary"&gt;Click me!&lt;/button&gt;
  &lt;p&gt;&lt;/p&gt;

  &lt;label&gt;
   &lt;input type="checkbox" ng-model="mySwitch1"&gt;Whether to display?
  &lt;/label&gt;

  &lt;button ng-show="mySwitch1" class="btn btn-primary"&gt;Click me!&lt;/button&gt;
  &lt;p&gt;&lt;/p&gt;

  &lt;label&gt;
   &lt;input type="checkbox" ng-model="mySwitch2"&gt;Whether to hide?
  &lt;/label&gt;

  &lt;button ng-hide="mySwitch2" class="btn btn-primary"&gt;Click me!&lt;/button&gt;
  &lt;p&gt;&lt;/p&gt;

  &lt;button ng-click="count = count + 1"&gt;Click me!&lt;/button&gt;
  &lt;p&gt;{{ count }}&lt;/p&gt;
  &lt;button ng-click="func()"&gt;Tell me what I think!&lt;/button&gt;

 &lt;/body&gt;
 &lt;script src="libs/"&gt;&lt;/script&gt;
 &lt;script&gt;

  ("app",[])
  .controller("ctrl",function($scope,$rootScope){
   $ = 10;
   $ = function(){
    alert("I popped up a window!");
   }
  })
 &lt;/script&gt;
&lt;/html&gt;

8. Angular form and input verification

[Form Verification in AngularJS]

1. Common verification operations in the form:

$dirty The form has record

The $valid field content is legal

The content of the $invalid field is illegal

$pristine The form has no record filled in

$error Error message that the form verification fails

2. During verification, you need to set the name attribute to the form and input that needs to be verified:

After setting the name for form and input, the form form information will be bound to the $scope scope by default. Therefore, you can use the .$ verification operation to obtain the verification result:

For example: .$dirty = "true" form has been filled in

.$invalid = "true" The form input is invalid

.$ = "true" form required but not filled

The verification supported by $error is required/minlength/maxlength/pattern/email/number/date/url, etc. . .

3. To avoid conflicts, for example, when using type="email", H5 will also perform verification operations. If you only want to use AngularJS verification, you can use the <form novalidate></form> attribute to disable the H5 own verification function;

&lt;!DOCTYPE html&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;link rel="stylesheet" href="libs/" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" /&gt;
  &lt;style type="text/css"&gt;
   .row{
    margin-bottom: 10px;
   }
   .row .col-xs-5{
    text-align: center;
   }
   .suc{
    border-color: #3c763d;
     -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
      box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
   }
   .suc:focus{
    border-color: #2b542c;
 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168;
   box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168;
   }

   .err{
    border-color: #a94442;
 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
   box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
   }
   .err:focus{
    border-color: #843534;
 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483;
   box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483;
   }
  &lt;/style&gt;
 &lt;/head&gt;
 &lt;body ng-app="app" ng-controller="ctrl"&gt;
 &lt;div class="container" style="width: 40%; margin: 50px auto; padding: 0px;"&gt;
  &lt;div class="panel panel-primary"&gt;
   &lt;div class="panel-heading"&gt;
    &lt;div class="panel-title" style="text-align: center;"&gt;
     User registration
    &lt;/div&gt;
   &lt;/div&gt;

   &lt;div class="panel-body"&gt;
    &lt;form action="" method="get" class="form-horizontal" name="myForm" novalidate&gt;
    &lt;div class="row" &gt;
     &lt;div class="col-xs-3"&gt;
      username:
     &lt;/div&gt;
     &lt;div class="col-xs-9"&gt;
      &lt;input type="text" class="form-control" ng-model="" name="name" ng-minlength="4" ng-maxlength="10" required ng-class="{suc:.$valid &amp;&amp; .$dirty,err:.$invalid &amp;&amp; .$dirty}"/&gt;
      &lt;p style="color: red; margin: 0px;" ng-show=".$invalid &amp;&amp; .$dirty"&gt;
       &lt;!--When there is a record that is illegal,pshow--&gt;
       &lt;span ng-show=".$"&gt;username必须填写!!!&lt;/span&gt;
       &lt;span ng-show=".$"&gt;username最少包含4Characters!!!&lt;/span&gt;
       &lt;span ng-show=".$"&gt;username最多包含10Characters!!!&lt;/span&gt;
      &lt;/p&gt;
     &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="row"&gt;
     &lt;div class="col-xs-3"&gt;
      Mail:
     &lt;/div&gt;
     &lt;div class="col-xs-9"&gt;
      &lt;input type="email" class="form-control" ng-model="" name="mail" required ng-class="{suc:.$valid &amp;&amp; .$dirty,err:.$invalid &amp;&amp; .$dirty}"/&gt;
      &lt;p style="color: red; margin: 0px;" ng-show=".$invalid &amp;&amp; .$dirty"&gt;
       &lt;!--When there is a record that is illegal,pshow--&gt;
       &lt;span ng-show=".$"&gt;Mail必须填写!!!&lt;/span&gt;
       &lt;span ng-show=".$"&gt;Mail格式不合法!!!&lt;/span&gt;
      &lt;/p&gt;
     &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="row"&gt;
     &lt;div class="col-xs-3"&gt;
      password:
     &lt;/div&gt;
     &lt;div class="col-xs-9"&gt;
      &lt;input type="password" class="form-control" ng-model="" name="pwd" pattern="^\w{6,18}$" required ng-class="{suc:.$valid &amp;&amp; .$dirty,err:.$invalid &amp;&amp; .$dirty}"/&gt;
      &lt;p style="color: red; margin: 0px;" ng-show=".$invalid &amp;&amp; .$dirty"&gt;
       &lt;!--When there is a record that is illegal,pshow--&gt;
       &lt;span ng-show=".$"&gt;password应为6-18Bit,And only letters、number、Underline&lt;/span&gt;
      &lt;/p&gt;
     &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="row"&gt;
     &lt;div class="col-xs-3"&gt;
      确认password:
     &lt;/div&gt;
     &lt;div class="col-xs-9"&gt;
      &lt;input type="password" class="form-control" ng-model="rePwd" name="rePwd" required ng-class="{suc:.$dirty&amp;&amp;rePwd==,err:.$dirty&amp;&amp;rePwd!=}"/&gt;
      &lt;p style="color: red; margin: 0px;" ng-show=".$dirty &amp;&amp; rePwd!="&gt;
       &lt;!--When there is a record that is illegal,pshow--&gt;
       两次password输入不一致!!!
      &lt;/p&gt;
     &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="row"&gt;
     &lt;div class="col-xs-5"&gt;
      &lt;input type="submit" value="register" class="btn btn-success" ng-disabled="myForm.$invalid || rePwd!=" /&gt;
     &lt;/div&gt;
     &lt;div class="col-xs-5"&gt;
      &lt;input type="button" value="Reset" class="btn btn-warning" ng-click="resets()" /&gt;
     &lt;/div&gt;
    &lt;/div&gt;
    &lt;/form&gt;
   &lt;/div&gt;
  &lt;/div&gt;
  &lt;pre&gt;
   {{}}
  &lt;/pre&gt;
 &lt;/div&gt;

 &lt;/body&gt;
 &lt;script src="libs/"&gt;&lt;/script&gt;
 &lt;script&gt;

   $ = function(){
    $ = ($);
   }
   $();
  })
 &lt;/script&gt;
&lt;/html&gt;

The above is all the content of this article. I hope that the content of this article will help you study or work. I also hope to support me more!