Οδηγία ng-keypress του AngularJS
Ορισμός και χρήση
ng-keypress
Η εντολή ενημερώνει το AngularJS για τις ενέργειες που πρέπει να εκτελέσει όταν χρησιμοποιείται το πλήκτρο του πληκτρολογίου σε συγκεκριμένο στοιχείο HTML.
In AngularJS ng-keypress
The directive does not override the original onkeypress event of the element, both will be executed.
The order of keystrokes is:
- Keydown (key pressed)
- Keypress (key pressed)
- Keyup (key released)
Example
An expression is executed each time a key is pressed:
<input ng-keypress="count = count + 1" ng-init="count=0" /> <h1>{{count}}</h1>
Syntax
<element ng-keypress="expression</element>
Support <input>
,<select>
,<textarea>
and other editable elements.
Parameters
Parameters | Description |
---|---|
expression | An expression that is executed when a key is pressed. |