苗火 Nicholas
[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>







发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容