New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails with ng-repeat #7
Comments
Hi, Duplicate of #2 I plan to refactor the directive and try using one ZeroClipboard instance for multiple instances of ng-clip. |
Ok. I tried that. I moved ZeroClipboard into Service and then triggered the behavior using Angular click handler. Here's the basic idea: 'use strict';
angular.module('ngClipboard', []).
value('ZeroClipboardConfig', {
path: '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.2.3/ZeroClipboard.swf'
}).
factory('clipService', ['ZeroClipboardConfig', function (ZeroClipboardConfig) {
var clip = new ZeroClipboard(null, {
moviePath: ZeroClipboardConfig.path,
trustedDomains: ['*'],
allowScriptAccess: 'always'
});
return {
clip: function(text) {
clip.flashBridge.setText(text); // doesn't copy... tried clip.setText too
}
};
}]).
directive('clipCopy', ['clipService', function (clipService) {
return {
scope: {
clipCopy: '&',
clipClick: '&'
},
restrict: 'A',
link: function (scope, element, attrs) {
element.on('click', function() {
clipService.clip(scope.$eval(scope.clipCopy));
if(angular.isDefined(attrs.clipClick)) {
scope.$apply(scope.clipClick);
}
});
}
};
}]); For some reason I couldn't get it to work, though... I might be missing something simple. Alternatively we could just wait till they resolve zeroclipboard/zeroclipboard#90 . Looks like they are testing a fix at the moment. Or you could swap zeroclipboard to some other alternative. For me it seems like a very bloated library considering what it is doing. In this case we don't need event handling etc. for instance. Just a copy hook (Flash bridge) is enough. |
Any luck w/ this? |
@markalanevans Yes. If you use ZeroClipboard version |
Working on it right now, Thanks ! |
Hi, As soon as you confirm, I'll create a new version and update README.md accordingly. |
@asafdav Seems to work! Thanks a lot. :) |
Awesome! Thanks for the follow up! On Wed, Jan 15, 2014 at 2:46 PM, Juho Vepsäläinen
|
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.
The text was updated successfully, but these errors were encountered: