AngularJS Basic ng keyup Simple Example
- 2021-07-07 06:04:43
- OfStack
AngularJS ng-keyup Directive
AngularJS instance
Code to execute when the key is released:
<!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-keyup="count = count + 1" ng-init="count=0" />
<h1>{{count}}</h1>
<p> This example calculates the variable every time the input box is released by pressing a key "count" Will automatically add 1 . </p>
</body>
</html>
Definition and usage
The ng-keyup instructions are used to tell AngularJS what is required to release the key on the specified HTML element.
The ng-keyup instruction does not override the element's native onkeyup event, and when the event is triggered, both the ng-keyup expression and the native onkeyup event are executed.
Event sequence of keystrokes:
1.Keydown
2.Keypress
3.Keyup
Grammar
<
element ng-keyup="expression"
>
<
/element
>
<
input
>
,
<
select
>
,
<
textarea
>
And other editable elements support this directive.
Parameter value
值 | 描述 |
---|---|
expression | 按键松开执行的表达式。 |
The above is the data collation of AngularJS ng-keyup instructions, and the follow-up will continue to be supplemented!