AngularJS ng-paste Directive Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The ng-paste Directive in AngularJS is used to specify custom behavior functions when the text in input fields is pasted into an HTML element. It can be used to call a function that will be triggered when the text is pasted into the input field. It is supported by <input>, <select> and <textarea>. Syntax: <element ng-paste="expression"> Content ... </element> Parameter: expression: It specifies what to do when the input is pasted into an HTML element. Example 1: This example describes the ng-paste directive in AngularJS, by specifying the boolean value that displays whether the text is pasted or not. HTML <!DOCTYPE html> <html> <head> <title>ng-paste Directive</title> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"> </script> <style> body { text-align: center; font-family: sans-serif; } h1 { color: green; } </style> </head> <body ng-app> <h1>GeeksforGeeks</h1> <h2>ng-paste Directive</h2> <div ng-init="ispaste=false;paste='Paste some text!'"> <textarea ng-paste="ispaste=true" ng-model="paste"> </textarea><br /> <pre>Paste status: {{ispaste}}</pre> </div> </body> </html> Output: Example 2: This example describes the ng-paste directive in AngularJS, where it specifies the number of times the text is pasted, its total count will be displayed accordingly. HTML <!DOCTYPE html> <html> <head> <title>ng-paste Directive</title> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"> </script> <style> body { text-align: center; font-family: sans-serif; } h1 { color: green; } </style> </head> <body ng-app=""> <h1>GeeksforGeeks</h1> <h2>ng-paste Directive</h2> <p>paste the "GeeksforGeeks" text</p> <input ng-paste="paste = paste + 1" ng-init="paste=0" value="GeeksforGeeks" /> <p> {{paste}} times text pasted.</p> </body> </html> Output: Comment More infoAdvertise with us Next Article AngularJS ng-src Directive V Vishal Chaudhary 2 Follow Improve Article Tags : Web Technologies AngularJS AngularJS-Directives Similar Reads AngularJS ng-style Directive The ng-style Directive in AngularJS is used to apply custom CSS styles on an HTML element. The expression inside the ng-style directive must be an object. It is supported by all the HTML elements. Syntax: <element ng-style="expression"> Content ... </element>Parameter: expression: It rep 2 min read AngularJS ng-pattern Directive The ng-pattern Directive in AngularJS is used to add up pattern (regex pattern) validator to ng-Model on an input HTML element. It is used to set the pattern validation error key if input field data does not match a RegExp that is found by evaluating the Angular expression specified in the ng-patter 2 min read AngularJS ng-value Directive The ng-value Directive in AngularJS is used to specify the value of an input element. This directive can be used to achieve the one-way binding for the given expression to an input element, especially when the ng-model directive is not used for that specific element. It is supported by <input> 2 min read AngularJS ng-src Directive The ng-src Directive in AngularJS is used to specify the src attribute of an <img> element, ie., it overrides the original src attribute for an <img> element. This attribute must be used if we have the Angular code inside of the src element. It ensures that the wrong image is not produce 2 min read AngularJS | ng-selected Directive The ng-selected Directive in AngularJS is used to specify the selected attribute of an HTML element. It can be used to select the default value specified on an HTML element. If the expression inside the ng-selected directive returns true then the selected option value will be displayed otherwise not 1 min read AngularJS ng-srcset Directive The ng-srcset Directive in AngularJS is used to specify the srcset attribute of an <img> element, ie, overriding the original srcset attribute of an <img> element. It helps to ensure that the wrong image is not produced until AngularJS has been evaluated. This directive must be used inst 2 min read Like