Home > Web Front-end > JS Tutorial > body text

Detailed explanation and simple example of AngularJS ng-blur directive

高洛峰
Release: 2017-01-10 11:18:15
Original
1355 people have browsed it

AngularJS ng-blur directive

AngularJS example

Execute expression when the input box loses focus (onblur):

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app="">
 
<input ng-blur="count = count + 1" ng-init="count=0" />
 
{{count}}
 
<p>实例中 "count" 变量记录了失去焦点的次数。</p>
 
</body>
</html>
Copy after login


Running result:

AngularJS ng-blur 指令详解及简单实例

0

The "count" variable in the instance records the number of times the focus is lost .

Definition and Usage

The ng-blur directive is used to tell AngularJS the expression that needs to be executed when the HTML element loses focus.
The ng-blur directive in AngularJS does not override the native onblur event. If this event is triggered, both the ng-blur expression and the native onblur event will be executed.

Syntax


, ,