This article mainly introduces the angularjs ng-keyup instruction.Here is the basic information of the ng-keyup instruction.And attached with code examples,Have

angularjs ng-keyup directive

angularjs example

Code executed when the key is released:

<! Doctype html>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<body ng-app="">
<input ng-keyup="count=count + 1" ng-init="count=0" />
<p>In this example, every time the key in the input box is released,The calculated variable "count" is automatically incremented by one.</p>

Definition and usage

The ng-keyup directive is used to tell angularjs what to do when the key is released on the specified html element.

The ng-keyup directive does not override the element's native onkeyup event. When the event is triggered,Both the ng-keyup expression and the native onkeyup event will be executed.

Sequence of keystrokes:





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

<input> ;,<select> ;,<textarea> ;, and other editable elements support the directive.

Parameter value

value description
expression Press the key to release the executed expression.

  • Previous Implementation method of js to obtain the absolute path of the uploaded file
  • Next jQuery set focus and make the cursor position at the end of the text