SoFunction
Updated on 2025-04-13

AngularJS basic ng-paste directive simple example

AngularJS ng-paste directive

AngularJS instance

Execute expressions when the text is pasted:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="/libs//1.4.6/"></script>
</head>
<body ng-app="">

<input ng-paste="count = count + 1" ng-init="count=0" value="Paste the text here!" />

<p>Pasteed {{count}} Second text。</p>

<p>
This example demonstrates the text when pasting in the input box,Calculate variables "count" Will automatically add 1。</p>
</body>
</html>

Definition and usage

ng-pasteDirectives are used to tell AngularJS text what to do when pasting on HTML elements.

ng-pasteDirectives will not overwrite the element's native onpaste event. When the event is triggered, both the ng-paste expression and the native onpaste event will be executed.

grammar

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

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

Parameter value

value describe
expression The expression that pastes the text onto the element.

The above is the basic information sorting out the AngularJS ng-paste instruction. We will continue to add relevant information in the future. Thank you for your support!