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>
Running result:
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
Parameter value
The above is a brief explanation of the AngularJS ng-blur instruction knowledge. I will continue to add more in the future. Thank you for your support!
For more detailed explanations and simple examples of AngularJS ng-blur instructions, please pay attention to the PHP Chinese website!