asafdav / ng-clip Goto Github PK
View Code? Open in Web Editor NEWCopy to clipboard using AngularJS
License: MIT License
Copy to clipboard using AngularJS
License: MIT License
It would be great if "usenocache" is enable.
Asafdav,
http://ngmodules.org/modules/ng-clip
links to a broken JSFiddle (... http://jsfiddle.net/asafdav/8YQcz/6/) , it should probably link to a working live demo, I'd suggest linking to the same plunkr that you link to on the github page: http://plnkr.co/edit/xwV5Yn?p=preview
Is there a reason that you still use version 1.x?
Cheers,
Emanuele.
The run block that configures ZeroClipboard is passing an unused "moviePath" configuration. This means we can no longer configure the path to the flash object.
run(['ngClip', function(ngClip) {
ZeroClipboard.config({
moviePath: ngClip.path,
trustedDomains: ["*"],
allowScriptAccess: "always",
forceHandCursor: true
});
}])
See the issue on ZeroClipboard:
zeroclipboard/zeroclipboard#323
In v2.x, I'll be updating the default configuration so that swfPath (the incoming replacement for moviePath) will be relative to the location of the ZeroClipboard JS file being used.
This is the commit that changed this option:
zeroclipboard/zeroclipboard@90b8a4e
I'd love to be able to define a global callback for on success and on failure where I could have my notification service say 'success!' or a failure occurred. This currently isn't possibly and isn't very DRY.
Per https://github.com/bower/bower.json-spec, "main"
should "not include minified files."
Updating this to conform to spec would be helpful for debugging in a dev environment. Bower dependencies are typically minified by developers themselves anyway.
support paste from clipboard
This solved the issue for me:
clipboard.setData('text/plain', scope.$eval(scope.clipCopy) + '');
Maybe we could use https://github.com/zenorocha/clipboard.js/ instead?
Hey,
Great idea with ng-clip! really looked for a solution like this.
I'm having trouble adding it to my project.
When I go mouseover the object I added the ng-clip directive to, I get this error.
Uncaught Error: Error calling method on NPObject
I tried adding
allowScriptAccess: "always",trustedDomains: location.hostaname
to the directive but no luck there...
Any ideas?
Thanks again!
I'm experimenting an issue when using multiple directives which has different instance scope modes.
One of them is bs-popover
from AngularStrap's project
button.btn-link(bs-popover, clip-copy="copyToClipboard()")
Acording to Angular docs:
Example scenarios of multiple incompatible directives applied to the same element include:
Multiple directives requesting isolated scope.
Multiple directives publishing a controller under the same name.
Multiple directives declared with the transclusion option.
Multiple directives attempting to define a template or templateURL.
Console trace
Error: [$compile:multidir] Multiple directives [bsPopover, clipCopy] asking for new/isolated scope on: <html>...</html>
I have applied ng-clip in my project it is working fine in desktop but not working on mobile devices
I looked through the source, and this feature does not seem to be implemented anymore? I wanted to be able to copy HTML into the clipboard so that it could pasted with formatting. Was this intentionally removed?
The fiddle example doesn't work, could you update it with a working one?
Hello. I have datatables with server side processing
I return in each row column like this:
->addColumn('token', function ($model) {
return '<button class="btn btn-sm btn-default" type="button" clip-copy="\'https://mysite.com/register?token=' . $model->activation_code . ' \'"><i class="fa fa-copy"></i></button>';
})
Looks like problem is that ng-clip inits on page load, but datatables returns all rows after page-load and ng-clip does not see those rows.
How can I re-init ng-clip so it would see those buttons ?
It looks like this module has a good number of stars. There are also some great PRs open and valid issues.
Is it still being maintained, do you need some help knocking this stuff out?
Is there any specific reason why we can't use ZeroClipboard.Core?
For some reason ng-clip fails with ng-repeat. Maybe it's related to directive binding somehow? It keeps on pointing at the first item. Fiddle.
With default usage ngClip loads the zero clipboard js file rather than the swf. Line 8 should be changed to :
this.path = '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.2.3/ZeroClipboard.swf';
Is somebody else having problems with
scope.$on('$destroy', function() {
client.off('dataRequested', onDataRequested);
client.unclip(element);
});
?
I have case where I jump to another page after copying stuff to clipboard and when returning to page containing ng-clip directive events (datarequested) stopped working.
So for me running this with
scope.$on('$destroy', function() {
ZeroClipboard.destroy();
});
works ok.
It this somehow possible?
I am trying to get it working to copy data that I get after http success request. I get some text but it only does the copy if I click twice. First time it leaves the old value.
I basically process set some text, process the value in PHP which returns a new value which I want to copy to clipboard. But it always doesn't pick up the first time. Is there a way to make it wait until $scope is ready. Tried various timeout, scope.apply methods but couldn't get it to work.
$scope.getTextToCopy = function() {
return $scope.rez;
};
$scope.copyCode = function(show_id) {
var textToCopy = "12345"
$http({
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
url: 'snippets/scripts/iframeObfuscate.php',
method: "POST",
data: $.param({
"param": textToCopy
})
}).success(function(data) {
$scope.rez = data;
});
};
Any advice is appreciated :)
p.s best bet is to invoke a method to copy in js file and not use the
data-clip-copy="getTextToCopy()" in html. I think that would solve the issue ?
Hey, there's no error handler which makes using the lib quite difficult.
First of all, thanks for your contribution, your code is organized and well structured.
When using parts of you code for my own implementation of retrieving a unique hash from the server upon interaction with the user via a deferred object, I ran into some troubles.
The ZeroClipboard event just don't seem to fire, tried:
setting priority above 0(up to 100),
an incognito window with no adons (add block, etc),
using a local instance of the script and swf, and also the following settings:
var clip = new ZeroClipboard( angular.element(element), {
moviePath: ZeroClipboardPath,
trustedDomains: ['*'],
allowScriptAccess: "always"
});
tried using angular.element() and $() on the element, even tried to use an jquery css selector with an explicit id, but now luck.
Any ideas?
Tried your original module, doesn't work either
Can you provide an unminified version in ./dest
Here is a fiddle that emphasizes the issue:
http://jsfiddle.net/8YQcz/12/
Hi,
I tested my app with ngClip and your demo on a few up-to-date browsers (Chrome, FF and IE) and it doesn't work on IE. Any fix for this?
Thanks,
Yaniv
when i have multiple buttons with ng-clip , it fails
The dom like this:
< input type = "text" ng-model = "hostname" />
< span class="input-group-addon" clip-copy="hostname" clip-click="copy2clipboard()" title="copy" tooltip> < a data-container="body"> < i class="fa fa-copy">
what I want is that after pressed span tag button, use clip-click attribute specified method copy2clipboard() to change span dom's title attribute to 'it is copied!'
Would you be interested in a PR to add another attribute, e.g. clip-click-fallback
, so that a fallback function may be fired in the event that flash is unavailable?
ZeroClipboard.isFlashUnusable()
returns if flash is unavailable. If true, I would bind the clip-click-fallback
function to the element, otherwise proceed with the rest of your linking function.
In my old app, I'd hide the element when flash wasn't detected by doing this:
var clip = new ZeroClipboard($("button.clipboard"));
clip.on('noflash wrongflash', () => $("button.clipboard").hide());
It would be nice if this was possible with an attribute like clip-hide-no-flash
In the Usage document, I think the document assumes that the user is already very familiar with ZeroClipboard and knows why and what to set the path of the .swf file to. However, as a new user I don't know it.
In the ZeroClipboard instructions.md file, it says: "... If this file is located in the same directory as your web page, then it will work out of the box. However, if the SWF file is hosted elsewhere, you need to set the URL like this...."
Since the file in question does not seem to be part of the installation, I assume it gets created by the software at some point.... as to where it should go, I don't see how I determine that.
Chrome is dropping Flash support, this will basically make this wonderful directive unusable.
http://plnkr.co/xwV5Yn
Nothing gets copied to clipboard.
When I use ng-clip in web page,it can work well.When I use it in the chrome app,it doesn't work.I use your demo first code segments in my project.
I've setted up a function to show a message saying that data was copied to the clipboard, but when I click it the text gets copied but nothing happens after... no message :(
$scope.copiedClick = () ->
logger.logSuccess = 'Data copied'
$scope.getPullUrlToCopy = (skinId) ->
return 'text to copy'
<button title="Copy Data" type="button" class="btn btn-info" clip-copy="getPullUrlToCopy(item.id)" clip-click="copiedClick()"><i class="fa fa-key"></i></button>
i have a problem about ng-clip
step 1: i copy a data by ctrl + c,it works well 'aaa'
step 2: i click a button (use ng-clip) 'bbb'
step 3: ctrl + v ,the result is 'aaa'
step 4: ctrl + v ,the result is 'bbb'
i don't know why , This is my code link.
Hi Asaf, I am now writing tests for this module using mocha, the problem is that for the module to be testable the ZeroClipboard instances will have to be stored inside a service \ factory, in order to call the getText() method from the test(probably service...)
Now I am thinking about about a good way to implement this, and the only way I've been able to come up with so far is a hash map that will contain the zeroClipboard object as value, and the key will be the element id(not good, don't want to force the users to set an id attribute for the element they bind the plugin to)
Any ideas?
Hi all,
with chrome I've no problem
I've tried with Firefox 39 (Ubuntu) your example http://plnkr.co/xwV5Yn and no one of the Copy button was working.
Please let me know how to fix it.
It seems the flash file gets loaded correctly, but the funcionality does not work at all. I tried both Chrome and Firefox with no success
I tried to put together a JSFiddle reproducing this, can anybody tell me what's the fix here?
http://jsfiddle.net/ztekqn4h/
Maybe I'm wrong, but it seems that there is no digest cycle called for rootScope on clip-copy, only for the actual scope.
I'm working on a Single Page Application written in Angular, where I'm trying to apply this module to a button
This seems to create an overlay with the flash object on top of the button. But when I click somewhere else to change the page (making the button disapear), the overlay stays there. It's still invisible, but I notice I can't over on anything where the button used to be
I'm creating a "copy code" function that currently is working perfectly copying HTML and SCSS. When I do an attempt to copy a field with JS, nothing happens. If I replace the JS with something else (text, HTML or CSS i.e) it works perfectly. How can we make the script copy JS code?
I have a directive that when clip-copy it should call parent function, but it does not.
Once navigated to the page with clip-copy directive used in, the page title will become
Assigned pagetitle Plus (htmlpagetitle#/htmlpagename/session id)and stays that way , the zeroclipboard version is v2.1.6 .
The bower.json
in release 0.1.2 specifies 0.1.1 as the version, which causes bower to complain and not install the module.
please, publish v0.2.6
Hi Asaf,
What is the best way to have bootstrap's tooltip and ng-clip working together?
The following does not work:
<a href="" clip-copy="getTextToCopy()" tooltip="copy to clipboard">Copy</a>
Thanks!
I tried demo page ( http://plnkr.co/xwV5Yn ) on different android devices. Seems not working on android device browsers.
Try using example fiddle: http://jsfiddle.net/asafdav/8YQcz/6/
Hello, thanks for working on this. I can't find ng-clip on bower. Can you please register it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.