AngularJS ng-paste directive
AngularJS instance
Execute expressions when the text is pasted:
<!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-paste="count = count + 1" ng-init="count=0" value="Paste the text to this!" /><p>Paste the text {{count}} times. </p><p>This example demonstrates that when text is pasted in the input box, the calculated variable "count" will automatically add 1. </p></body></html>Definition and usage
The ng-paste directive is used to tell AngularJS what to do when pasting text on HTML elements.
The ng-paste directive will not overwrite the element's native onpaste event. When the event is triggered, both the ng-paste expression and the native onpaste event will be executed.
grammar
<element ng-paste="expression"></element>
<input>, <select>, <textarea> and other editable elements support this directive.
Parameter value
| value | describe |
|---|---|
| Expression | The expression that pastes the text onto the element. |
The above is the basic information sorting out the AngularJS ng-paste instruction. We will continue to add relevant information in the future. Thank you for your support!