Skip to content
Related Articles

Related Articles

AngularJS | ng-copy Directive

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 28 Mar, 2019

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.


<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>
    <title>ng-copy Directive</title>
    <script src=
<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">
        <pre>Copied status: {{isCopy}}</pre>

Before copy the element:
After copy the element:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!