1

Is there a way in Angular2 to get text from the clipboard? I found a lot of information about copying to the clipboard, but nothing regarding the other way around.

Lars
  • 23
  • 4
  • 1
    I'm sorely tempted to downvote this question for lack of effort. Please do some research before asking as their are lots of duplicates and they are easy to find, in fact I'd imagine this got suggested to you when typing in the question – Liam Feb 19 '18 at 10:37

1 Answers1

1

you can use this, but this is in a javascript way, you may need to modify this in typescript with event binding on which you want to show.

window.clipboardData.getData('Text')

but it will work in some browsers. However, many browsers where it does work will prompt the user as to whether or not they wish the web page to have access to the clipboard.

Hrishikesh Kale
  • 6,140
  • 4
  • 18
  • 27
  • Typescript is a superset of Javascript, everything that works in Javascript will also work in typescript – Liam Feb 19 '18 at 10:35
  • yes, you are right @Liam, but this should also work with the requirements. so sometimes there are syntax changes according to requirements. – Hrishikesh Kale Feb 19 '18 at 10:37