English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

AngularJS ng-copy instruction

AngularJS Reference Manual

!DOCTYPE html
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/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 has been copied {{count}} times.</p>
<p>In the example, the value of the variable "count" is automatically incremented when the text in the input box is copied. 1。</p>
</body>
</html>
Test to see ‹/›

Definition and Usage

ng-copy The directive is used to tell AngularJS what operation to perform when the text of the HTML element is copied.

ng-copy The directive does not override the original oncopy event of the element, When the event is triggered,ng-copy Both the expression and the original oncopy event will be executed.

Syntax

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

All HTML elements support it.

Parameter Value

ValueDescription
expressionExpression executed when the element text is copied.

AngularJS Reference Manual