Angular2 component with clipboardData property

I have an Angular2 component with a method to paste data from the clipboard:

inputPaste(event){ let clipboardData = event.clipboardData; ... 

}

This method does not work for IE10 +, but IE has a window object with the bufferboardData property, but the typescript compiler throws an error:

 inputPaste(event){ let clipboardData = event.clipboardData || window.clipboardData; //error 'clipboardData' does not exist on type Windows ... 

}

I found a solution that we should use the angular2 -clipboard directive, but I will not use it.

How can I use 'windows.clipboardData' in typescript?

+5
source share
1 answer

I found a solution:

 inputPaste(event){ let clipboardData = event.clipboardData || (<any>window).clipboardData; //typecasting to any or || window['clipboardData']; //access like to array ... } 
+5
source

All Articles