I have an Angular2 component with a method to paste data from the clipboard:
inputPaste(event){
let clipboardData = event.clipboardData;
...
}
This way doesn't work for IE10+, but IE have a window object with a property clipboardData, but typescript compilator throws an error:
inputPaste(event){
let clipboardData = event.clipboardData
|| window.clipboardData; //error 'clipboardData' does not exist on type Windows
...
}
I have found a solution, that we must use angular2-clipboard directive, but I wan't to use it.
How can I use 'windows.clipboardData'
in typescript?
I have found a solution:
inputPaste(event){
let clipboardData = event.clipboardData
|| (<any>window).clipboardData; //typecasting to any
or
|| window['clipboardData']; //access like to array
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With