Browser support: Chrome 43+, Firefox 41+, Opera 29+, IE10+, Safari 10+ and Mobile Safari 10+.
See the demo.
$ npm install angular-clipboard --save
angular-clipboard has no other dependencies than Angular itself.
Require angular-clipboard as a dependency for your app:
Copy text from an input field by clicking a button:
You can supply a method to be called for the
on-error event. The
on-error function will be called with the error object as argument
supported property can be used to detect browser support for the clipboard feature.
Use as service
You can also invoke the copy to clipboard action directly by injecting the
clipboard service. Just remember it has to be in a click event, as clipboard access requires user action.
Use with a module loader
If you are using a module loader, you can import the module name when requiring it in angular. Works with any AMD/UMD/CommonJS module loader.