# How do I add a copyToClipboard function in the following code?

I have tried many ways to do it please help me with this. There’s a icon which gives a clipboard of the link to email. I have to remove that clipboard and add copytoclipboard when clicked on the icon. I have commented the previous code where it gave the clipboard of the link.

$scope.copyToClipBoard =function (tranxNo,messageID,userCode,docCode,processCode, origin,company,originCompany,isInterInstance) { // need messageID,us_login,InstanceId,Flg to mark this unique url. var userCode=$('.loggedInUserCode').val();
var curTrnxNo = $("#trnxNo").val(); var curBpCode =$("#bpCode").val();

var clipBoardId="";
if(docCode.indexOf("PR0")==0)
clipBoardId = messageID+"_"+curBpCode;
else
clipBoardId = curTrnxNo+"_"+curBpCode;
var clipBoardDiv=$(".clipBoardDiv_"+clipBoardId);$(".clipBoardInput_"+clipBoardId).val("");

var parmUrl="?callback=JSON_CALLBACK&authToken="+$scope.authToken +"&messageID="+messageID +"&processCode="+processCode +"&tranxNo="+tranxNo +"&userCode="+userCode +"&origin="+origin +"&company="+company +"&originCompany="+originCompany +"&isInterInstance="+isInterInstance; var mailURL=$scope.realPath+streamMailPath+parmUrl;
\$http.jsonp(mailURL).success(function(data) {
if(data!="undefined")
{
replyTo=data.reply_To;

//openClipBoardDialog(tranxNo,messageID,docCode,processCode,replyTo);

}
}).error(function(data, status, headers, config) {
});
};


Source: AngularJS