Introduction
AngularJS provides many built-in directives. In this article we will discuss about ngCopy, ngCut and ngPaste directives.
ngCopy
This directive is useful to define custom behavior on copy event. It executes at highest priority.
Syntax
<input, textarea, select, a, window ng-copy="expression">
...
</nput, textarea, select, a, window>
Example
The following code count how many times we copy the content of textbox using "ctrl + C" keyboard command or context menu.
HTML
- <h4>ngCopy Example</h4>
- <div ng-controller="HomeController">
- <input ng-copy="copy()">
- <br /> Copy count: {{countCopy}}
- </div>
- var app = angular.module("app", []);
- app.controller("HomeController", function ($scope)
- {
- $scope.countCopy = 0;
- $scope.copy = function ()
- {
- $scope.countCopy = $scope.countCopy + 1;
- }
- });

ngCut
This directive is useful to define custom behavior on cut event. It executes at highest priority.
Syntax
<input, textarea, select, a, window ng-cut="expression">
...
</nput, textarea, select, a, window>
Example
The following code count how many times we cut the content of textbox using "ctrl + X" keyboard command or context menu.
HTML
- <h4>ngCut Example</h4>
- <div ng-controller="HomeController">
- <input ng-cut="cut()">
- <br /> Cut count: {{countCut}}
- </div>



Santhakumar MunuswamyPosted Dec 23, 2015, 3:35 PM
Thanks for nice article
Ankur MistryPosted Dec 16, 2015, 3:18 AM
nice share