English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script> </head> <body ng-app=""> <input ng-paste="count = count" + 1" ng-init="count=0" value="Paste text here!" /> <p>Pasted {{count}} times of text.</p> <p> This example demonstrates that when text is pasted into the input box, the variable "count" will automatically increase. 1。</p> </body> </html>Test and see ‹/›
ng-paste The directive is used to tell AngularJS what operation needs to be performed when text is pasted onto an HTML element.
ng-paste The directive does not override the element's native onpaste event, when the event is triggered,ng-paste Both the expression and the native onpaste event will be executed.
<element ng-paste="expression"></element>
<input>, <select>, <textarea> and other editable elements support this directive.
Value | Description |
---|---|
expression | The expression executed when text is pasted onto an element. |