0

Thanks for looking. I am implementing ng-clip in my project successfully for various tasks such as copying a value to the clipboard when a user clicks a button. Of course this is handled declaratively like so:

<a clip-click-fallback="CopyStuff()" clip-copy="ModelToBeCopied">Foo</a>

I now have a need to add an item to the clipboard from the Angular controller, specifically, a string that is returned from the server in a call back function:

$scope.Callback = function(response){

//How do I copy the response to the clip board??

}

Any help is appreciated.

Matt Cashatt
  • 23,490
  • 28
  • 78
  • 111

1 Answers1

1

ng-clip is a directive that uses ZeroClipboard, a flash based solution. You can't use ng-clip in a controller. Copying to the clipboard without user interaction is a general Javascript challenge, not one specific to Angular.

See this question for possible solutions: How do I copy to the clipboard in JavaScript?

Community
  • 1
  • 1
Anid Monsur
  • 4,538
  • 1
  • 17
  • 24