I was actually looking to get the content of clipboard using angular JS to simulate a copy paste thing.
相关问题
- angularJS: ui-router equivalent to $location.searc
- Separate AngularJS Controllers Into Separate Files
- Markdown to clipboard as rich text
- Angular ngAnimate not working first time on page l
- Ionic Spinner not showing up
相关文章
- Passing variable through URL with angular js
- Watch entire object (deep watch) with AngularJS
- Angular ng-if change span text
- How to add clipboard support to Matplotlib figures
- Can ng-show directive be used with a delay
- AngularJS $routeParams vs $stateParams
- Multiple parameters in AngularJS $resource GET
- How to set class/style of accordion heading in Ang
here's a concise version I use -
A completely different approach:
I need to copy & paste text between windows, so I used this to save (copy) the data to local storage. Then, in the other window, I load it out of local storage, using the same key, and I can then 'paste' is as I like.
I created a directive for copy to clipboard which is using the document.execCommand() method.
Directive
Html
I had the same issue and I used angular-clipboard feature[1] which uses new Selection API and Clipboard API available in the latest browsers.
First we have to install angular-clipboard lib, i'm using bower.
To import the module use following in html.
To set values to element using $scope in controller
Load the clipboard module using,
This works for Chrome 43+, Firefox 41+, Opera 29+ and IE10+.
Its simple & worked fine.
[1] https://www.npmjs.com/package/angular-clipboard
Thanks,
BTW, if using Angular to copy to clipboard with a Chrome Packaged App, do the following:
Put a function in your controller like: