Home>

This article mainly introduces the angularjs ng-keydown instruction.Here we have organized the basic information of the ng-keydown instruction.And attached the code,Have

angularjs ng-keydown directive

angularjs example

Code executed when the key is pressed:

<! 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-keydown="count=count + 1" ng-init="count=0" />
<h1>{{count}}</h1>
<p>In this example, every time a key is pressed in the input box,The calculated variable "count" is automatically incremented by one.</p>
</body>
</html>

Definition and usage

ng-keydowndirective is used to tell angularjs what action is required when pressing a key on the specified html element.

ng-keydownThe directive does not override the element's native onkeydown event. When the event is triggered,Both the ng-keydown expression and the native onkeydown event will be executed.

Sequence of keystrokes:

1.keydown

2.keypress

3.keyup

grammar

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

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

Parameter value

value description
expression An expression executed by pressing a key.

  • Previous Simple implementation of seven cattle image processing API using Golang
  • Next Implementation method of js to obtain the absolute path of the uploaded file