angular中复制文字到剪切板
function copyToClipboard(oElement, value) { var aux = document.createElement("input"); if (oElement) { var content = oElement.innerHTML || oElement.value; } var _content = value || content; aux.setAttribute("value", _content); document.body.appendChild(aux); aux.select(); document.execCommand("Copy"); document.body.removeChild(aux); }
document.execCommand('Copy')支持IE6+、firefox9+、chrome、safari6+。
在angular中的使用方法:
<i class="copy-icon" uib-popover="点击复制" popover-trigger="'mouseenter'" ng-click="copy_content(null, item.video_id)"></i>
控制器:
$scope.copy_content = function(oElement, value) { copyToClipboard(oElement, value); growl.addSuccessMessage("已复制到剪切板", {ttl: bpo_prompt.success}); };
- 上一篇 »python获取剪切板的内容
- 下一篇 »python自动化操作——复制文件到剪切板发送微信