Ng-clip copy to clipboard does not work

I am using ng-clip using some tutorials. I do it like in the textbook, but it does not work. i included Zeroclipboard.min.js, angular.js, ngClip.js

The html looks like.

<div ng-app="clip"> <button clip-copy="getTextToCopy()">Copy</button> </div> 

Script looks ..

  angular.module('clip', ['ngClipboard']); function Main($scope) { $scope.getTextToCopy = function() { return "ngClip is awesome!"; } $scope.doSomething = function () { console.log("NgClip..."); } } 

Can someone tell me where I was wrong! Thanks.

+6
source share
1 answer

I ran into the same problem; The fix is ​​to include js files as shown below and launch the webpage on the server . Create a folder in tomcat >> webapps and paste the web page there. Now view the page at the link

 http://localhost:8080/(folderName)/(pageName).html 
  <script src="http://asafdav.imtqy.com/ng-csv/javascripts/ngClip.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.1.7/ZeroClipboard.min.js"></script> <script> angular.module('clip', ['ngClipboard']); function Main($scope) { $scope.getTextToCopy = function() { return "ngClip is awesome!"; } $scope.doSomething = function () { console.log("NgClip..."); } } </script> <html> <body ng-app="clip" ng-controller="Main"> <h1> ngClip Example </h1> <button type="button" clip-copy="getTextToCopy()" clip-click="doSomething()">Copy</button> </body> </html> 
+5
source

Source: https://habr.com/ru/post/974089/


All Articles