app.directive('copyPost', ['$window', '$filter', 'ZeroClipboardPath', function ($window, $filter, ZeroClipboardPath) {
return {
scope: {
postFn: '&',
},
restrict: 'A',
link: function (scope, element, attrs) {
ZeroClipboardPath = ZeroClipboardPath || '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.1.7/ZeroClipboard.min.js';
var clip = new ZeroClipboard( angular.element(element), {
moviePath: ZeroClipboardPath,
trustedDomains: ['*'],
allowScriptAccess: "always"
});
clip.on('mousedown', function(client) {
console.log('shit works');
scope.postFn().then(function(data){
client.setText(data.data[0].external_url);
});
});
}
}
}]);
postFn gets the following function, which returns an HTTP promise(tested without the plugin, and the correct value is returned from the function into
jobsServ.shareObject = function(object, identifier, data){
if(object == 'job')
return $http.post(utils.getBaseUrl() + '/jobs/' + identifier + '/share', data, utils.getConfig());
else if(object == 'company')
return $http.post(utils.getBaseUrl() + '/companies/' + identifier + '/share', data, utils.getConfig());
});
ZeroCLipboard script:
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.1.7/ZeroClipboard.min.js"></script>
Problem: non of the ZeroCLipboard event are not firing.
Already attempted the following: 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:
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, anyone?
I don't think it's an Angular issue, so I'd recommend keeping the primary discussion on the GitHub issue you opened (#283) rather than spreading it too thin... otherwise people on SO are going to be missing a lot of the details from the GitHub issue.
See my latest update on the GH issue for an identified potential error. In particular:
If your ZeroClipboardPath
argument is empty, the fallback isn't going to work because you're pointing the moviePath
to a JS file rather than the Flash SWF:
ZeroClipboardPath = ZeroClipboardPath || '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.1.7/ZeroClipboard.min.js';
Should be:
ZeroClipboardPath = ZeroClipboardPath || '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.1.7/ZeroClipboard.swf';