From 2421a7347509191e33cba2122af16f5ee5f3e6ff Mon Sep 17 00:00:00 2001 From: Oliver Wienand Date: Tue, 10 Jul 2018 14:01:15 +0200 Subject: [PATCH] Also allow to bind a function to get the content to copy to the clipboard during export to clipboard --- src/ngclipboard.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ngclipboard.js b/src/ngclipboard.js index 6fd3181..e1fee34 100644 --- a/src/ngclipboard.js +++ b/src/ngclipboard.js @@ -18,11 +18,17 @@ restrict: 'A', scope: { ngclipboardSuccess: '&', - ngclipboardError: '&' + ngclipboardError: '&', + ngclipboardText: '&' }, - link: function(scope, element) { + link: function(scope, element, attr) { //constructor for clipboardjs changed to ClipboardJS - var clipboard = new ClipboardJS(element[0]); + var clipboard; + if (attr.hasOwnProperty('ngclipboardText')) { + clipboard = new ClipboardJS(element[0], {text: scope.ngclipboardText}); + } else { + clipboard = new ClipboardJS(element[0]); + } clipboard.on('success', function(e) { scope.$apply(function () {