VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angularjs-ng-copy-directive/

⇱ AngularJS ng-copy Directive - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS ng-copy Directive

Last Updated : 8 Aug, 2022

The ng-copy Directive in AngularJS is used to specify the custom behavior functions during the copy of the text in input text fields. It can be used when we want to call a function that will be triggered when the text is copied from the input field. It is supported by all input elements. The element's original oncopy event will not be overridden with the ng-copy directive when both are executing.

Syntax:

<element ng-copy="expression"> 
 Contents... 
</element>

Parameter:

  • expression: It specifies what to do when the element is copied.

Example 1: This example uses the ng-copy Directive to display a message when an element will copy. 

Output:

👁 Image
 

Example 2: This example describes the use of the ng-copy Directive in AngularJS where it specifies that the number of times the given text will be copied, its total count will be displayed accordingly.

Output:

👁 Image
 
Comment

Explore