AngularJS ng-copy directive
AngularJS instance
Execute expressions when the text in the input box is copied:
<!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-copy="count = count + 1" ng-init="count=0" value="Copy this text" /><p>The text is copied {{count}} times. </p><p>The value of the variable "count" in the instance will automatically increase by 1 when the text in the input box is copied. </p></body></html>Note: The value of the variable "count" in the instance will automatically increase by 1 when the text in the input box is copied.
Definition and usage
The ng-copy directive tells AngularJS what to do when HTML element text is copied.
The ng-copy directive will not overwrite the element's original oncopy event. When the event is triggered, both the ng-copy expression and the original oncopy event will be executed.
grammar
<element ng-copy="expression"></element>
All HTML elements are supported.
Parameter value
| value | describe |
|---|---|
| Expression | An expression executed when the element text is copied. |
The above is a compilation of the basic information of the ng-copy directive, and it is for reference by friends who study AngularJS.