Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-clip copy to clipboard is not working

I'm implementing the ng-clip using some tutorials. i'm doing it as it is in the tutorial but it's not working. i included Zeroclipboard.min.js, angular.js, ngClip.js

Html looks like..

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

Script looks like..

    angular.module('clip', ['ngClipboard']);

    function Main($scope) {
        $scope.getTextToCopy = function() {
    return "ngClip is awesome!";
        }

    $scope.doSomething = function () {
    console.log("NgClip...");
        }
    }

can anyone suggest me where i went wrong! Thanks.

like image 272
bharat Avatar asked Aug 20 '14 10:08

bharat


1 Answers

I faced the same problem; the fix is to include the js files as shown below and Run the web page on server. Create a folder in tomcat>>webapps and paste the webpage there. Now view the page at url

http://localhost:8080/(folderName)/(pageName).html
 <script src="http://asafdav.github.io/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>
like image 164
Orchid Avatar answered Nov 02 '22 20:11

Orchid