zoukankan      html  css  js  c++  java
  • 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});
            };
  • 相关阅读:
    磁盘
    磁盘接口
    Linux help websites
    [SOJ] 1282. Computer games (KMP)
    [SOJ]1753 解码
    hdu 3473 裸的划分树
    hdu 4417 划分树
    hdu 4665 搜索
    hdu 4340 树状DP
    hdu 4005 边连通度与缩点
  • 原文地址:https://www.cnblogs.com/bagexiaowenti/p/8012127.html
Copyright © 2011-2022 走看看