AngularJS Basic ng paste Simple Example

  • 2021-07-07 06:11:06
  • OfStack

AngularJS ng-paste Directive

AngularJS instance

Execute an expression when text is pasted:


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/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 into this !" />

<p> Pasted  {{count}}  Secondary text. </p>

<p>
 This example demonstrates how to calculate variables when text is pasted in an input box  "count"  Will automatically add  1 . </p>
</body>
</html>

Definition and usage

The ng-paste directives are used to tell AngularJS what to do when text is pasted on an HTML element.

The ng-paste instruction does not override the element's native onpaste event, and when the event is triggered, both the ng-paste expression and the native onpaste event are executed.

Grammar

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

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

Parameter value

描述
expression 文本粘贴到元素上执行的表达式。

The above is the basic data collation of AngularJS ng-paste instruction, and continue to supplement relevant data in the future. Thank you for your support!


Related articles: