Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-paste not working in angular2

Tags:

angular

I'm trying to prevent pasting into a textbox using ng-paste in angular2 by cancelling the paste event. I got this to work in angularJS but not in angular2. Am I doing something wrong or does it not work in angular2?

<input type="text" #username class="form-control" id="username" required 
placeholder="Username" value="{{userName}}" ng-paste="$event.preventDefault()">
like image 368
Rich Avatar asked Dec 03 '25 14:12

Rich


1 Answers

use (paste)="$event.preventDefault()" or (paste)="false".

like image 96
Pengyy Avatar answered Dec 06 '25 07:12

Pengyy