The ng-copy Directive in AngularJS is used to specify the custom behavior functions during copy of text in input text fields. It can be used when we want to call a function which will be triggered when the text is copied from the input field. It is supported by all input elements.
Syntax:
<element ng-copy="expression"> Contents... </element>
Where expression tells what to do when the element is copied.
Example: This example uses ng-copy Directive to display a message when element will copy.
<!DOCTYPE html> <html> <head> <title>ng-copy Directive</title> <script src= </script> </head> <body ng-app style="text-align:center"> <h1 style="color:green">GeeksforGeeks</h1> <h2>ng-copy Directive</h2> <div ng-init="isCopy=false; copy='Copy this text!'"> <textarea ng-copy="isCopy=true" ng-model="copy"> </textarea> <br> <pre>Copied status: {{isCopy}}</pre> </div> </body> </html> |
Output:
Before copy the element:

After copy the element:

Recommended Posts:
- AngularJS | ng-show Directive
- AngularJS | ng-init Directive
- AngularJS | ng-if Directive
- AngularJS | ng-dblclick Directive
- AngularJS | ng-keypress Directive
- AngularJS | ng-keydown Directive
- AngularJS | ng-keyup Directive
- AngularJS | ng-href Directive
- AngularJS | ng-focus Directive
- AngularJS | ng-hide Directive
- AngularJS | ng-disabled Directive
- AngularJs | ng-list Directive
- AngularJS | ng-mouseup Directive
- AngularJS | ng-mousedown Directive
- AngularJS | ng-maxlength Directive
- AngularJS | ng-minlength Directive
- AngularJS | ng-mousemove Directive
- AngularJS | ng-mouseover Directive
- AngularJS | ng-mouseleave Directive
- AngularJS | ng-mouseenter Directive
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

