AngularJS ng-keyup 指令

定义和用法

ng-keyup 指令向 AngularJS 告诉在特定 HTML 元素上使用键盘时应执行的操作。

AngularJS ng-keyup The directive will not override the original onkeyup event of the element, both of which will be executed.

The order of keystrokes is:

  1. Keydown (keyboard press down)
  2. Keypress (keyboard press)
  3. Keyup (keyboard release)

Example

Execute an expression each time a key is pressed:

<input ng-keyup="count = count + 1" ng-init="count=0" />
<h1>{{count}}</h1>

Try it yourself

Syntax

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

Support <input>,<select>,<textarea> and other editable elements.

Parameters

Parameters Description
expression An expression to be executed when the key is completed.