Home>

angularjs ng-blur directive

angularjs example

Execute the 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>The "count" variable in the example records the number of times the focus has been lost.
</p>
</body>
</html>

operation result:

0

The "count" variable in the example records the number of times the focus has been lost.

Definition and usage

The ng-blur directive is used to tell the angularjs html element to execute the expression when it loses focus.

The ng-blur directive in angularjs does not override the native onblur event. If the event is triggered,Both the ng-blur expression and the native onblur event are executed.

grammar

<element ng-blur="expression"></element>

<a> ;,<input> ;,<select> ;,<textarea> ;, window object support.

Parameter value

value description
expression An expression that is executed when the focus is lost.

  • Previous 57 of Manipulating Data in ASPNET 20: Caching Data in a Hierarchical Architecture
  • Next Fifty-sixth of Manipulating Data in ASPNET 20: Using ObjectDataSource to Cache Data