Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get pasted value using ngPaste directive when jquery is loaded before angular.js?

I'm having problems when i try to get the pasted data using ng-paste directive.

<input ng-model="evidence.url" ng-paste="getEvidenceInfos(evidence, $event.clipboardData.getData('text/plain'))">

When the jquery is loaded after angular, it works fine.
How to do when jquery is loaded before angular ?

<input ng-model="evidence.url" ng-paste="getEvidenceInfos(evidence, $event)">

$scope.getEvidenceInfos = function(evidence, event) {
  $(event.currentTarget).val() // doesn't work
  $(event.target).val() // doesn't work
}
like image 743
Sandro Simas Avatar asked Dec 14 '22 22:12

Sandro Simas


1 Answers

When jQuery is loaded before angular, it is used within angular instead of jQuery lite which is built into angular. If full jQuery is used, you will receive a jQuery event. The raw event can be found in the property originalEvent.

$scope.getEvidenceInfos = function(evidence, event) {
    var pastedData = event.originalEvent.clipboardData;
}
like image 76
Joel Jeske Avatar answered Feb 02 '23 01:02

Joel Jeske