I want to disable copy paste in a textarea using angularJs. I tried to do so with ng-paste, like so:
Controller:
angular.module('inputExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.val = '1';
$scope.past = function() {
console.log("d");
$scope.val =" ";
}
}]);
HTML:
<input ng-paste="past()" ng-model="val" ng-pattern="/^d+$/" name="anim" class="my-input" />
Input box has old data ( the initial paste data).
Blocking paste works the second time around, that is if I paste the data into input box, the data will be present, but on a second paste the data won't paste, but the old data value is not removed.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…