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

AngularJS ng-paste command

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-paste="count = count" + 1" ng-init="count=0" value="Paste text here!" />
<p>Pasted {{count}} times of text.</p>
<p>
This example demonstrates that when text is pasted into the input box, the variable "count" will automatically increase. 1。</p>
</body>
</html>
Test and see ‹/›

Definition and Usage

ng-paste The directive is used to tell AngularJS what operation needs to be performed when text is pasted onto an HTML element.

ng-paste The directive does not override the element's native onpaste event, when the event is triggered,ng-paste Both the expression and the native onpaste event will be executed.

Syntax

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

<input>, <select>, <textarea> and other editable elements support this directive.

Parameter Value

ValueDescription
expressionThe expression executed when text is pasted onto an element.

AngularJS Reference Manual