To facilitate a copy to clipboard pattern, we will utilise NGClip, which in turn uses the ZeroClipboard library.
Add the following to your package.json files
Include the correct JavaScript files in the JavaScript sprockets
# Angular Clipboard
window.ZeroClipboard = require "zeroclipboard"
require 'ng-clip'
Set ngClipboard as a dependency
angular.module 'app', [ 'ngClipboard' ]
Add the provider and path to the SWF file into your angular app config
config = ( ngClipProvider ) ->
ngClipProvider.setPath '/assets/swf/ZeroClipboard.swf'
Add the provide to the inject
config.$inject = [
'ngClipProvider'
]
Add clip-copy directive to the desired element, example:
= codeBlender "clipboard", "atom", { model: "clipboard.copy1" }
<button class='btn btn-default btn-primary' clip-copy='clipboard.copy1' type='button'>
Copy
</button>
Utilises clipboardJS to copy
Title | URL |
---|---|
Zero Clipboard | https://github.com/zeroclipboard/zeroclipboard |
NG Clip | https://github.com/asafdav/ng-clip |
angular-clipboard | https://github.com/omichelsen/angular-clipboard |
ClipboardJS | https://clipboardjs.com/ |
Copy to clipboard | https://www.sitepoint.com/javascript-copy-to-clipboard/ |
Task | Date |
---|---|
Move the required ngClipProvider.setPath to the controller if possible | |
Add clipboardJS example | |
Create the DOM interaction as an angular directive | |
Move text into locale | |
Make this more angular - use ng-class to change tabs for instance and scope to access the contents |