Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZeroClipboard + angular, multiple instances

app.directive('copyPost', ['$window', '$filter', 'ZeroClipboardPath', function ($window, $filter, ZeroClipboardPath) {
    return {
      scope: {
        postFn: '&',
        postSuccess: '&',
      },
      restrict: 'A',
      terminal: true,
      prioriry: 10,
      link: function (scope, element, attrs) {
        scope.disaplyValue = 'Copy';
        ZeroClipboardPath = 'lib/zeroclipboard/ZeroClipboard.swf';
        var clip = new ZeroClipboard( $(element), {
          moviePath: ZeroClipboardPath    
        });
        clip.on('dataRequested', function(client, args) {
          scope.postFn().then(function(data){
            client.setText(data.data[0].external_url);
            scope.postSuccess();
          });  

        });
      }
    }
  }]);

Creating multiple instances of this directive makes the swf object to trigger the event only for the first instance over the the entire application(same link copied).

obviously I have more than one link that I would like to allow my user to copy in my application.

Any help is much appreciated

like image 926
Oleg Belousov Avatar asked Dec 09 '13 14:12

Oleg Belousov


1 Answers

This 'singleton' behavior was fixed in the latest release 1.3.0 beta.

like image 85
Oleg Belousov Avatar answered Oct 19 '22 15:10

Oleg Belousov