AngularJS ng-keyupDirective

AngularJS 参考手册AngularJS Reference Manual


AngularJS Example

Code executed when a key is released:

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

<h1>{{count}}</h1>

Try it Yourself »

Definition and Usage

ng-keyupThe directive is used to tell AngularJS what to do when a key is released on the specified HTML element.

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

Order of keyboard events:

  1. Keydown
  2. Keypress
  3. Keyup

Syntax

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

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


Parameter Value

Value Description
expression The expression to execute when a key is released.

AngularJS 参考手册AngularJS Reference Manual

Other Extensions