[angularJS]How to use clipboard in angularJS

2015-11-24 写技术

1.Include three files in web page:

ngClip.js

ZeroClipboard.js

ZeroClipboard.swf


2.Set `ngClipboard` as a dependency in your module.

var myapp = angular.module('myapp', ['ngClipboard']);

3.Update the .swf path location using ngClipProvider.

myapp.config(function  ngClipProvider) {

ngClipProvider.setPath("js/ZeroClipboard.swf");

...

}

4.Add clip-copy to the wanted element like this:

 <button clip-copy="head_copy()" clip-click="clip_click()">Copy to clipboard</button>

5.Set function in javascript.

<script>

function head_copy(){

return "Here is the content to be copied";

}


function clip_click(){

alert("Copy to clipboard OK!");

}

</script>

标签: angularJS

发表评论:

Powered by anycle 湘ICP备15001973号-1