Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular2中文件的DOM粘贴事件_Angular_Clipboard - Fatal编程技术网

Angular2中文件的DOM粘贴事件

Angular2中文件的DOM粘贴事件,angular,clipboard,Angular,Clipboard,我正在尝试将csv文件粘贴到Angular 6应用程序的div容器中。但是,“我的剪贴板”数据的“项目”属性始终为空。 有人成功地实现了这一点吗 <div class="entries-list" (paste)="onPaste($event)"></div> 要获取粘贴的文本,必须使用getData方法,如下所示: onPaste(event) { console.log(event.clipboardData.getData('Text')); } 正如

我正在尝试将csv文件粘贴到Angular 6应用程序的div容器中。但是,“我的剪贴板”数据的“项目”属性始终为空。 有人成功地实现了这一点吗

<div class="entries-list" (paste)="onPaste($event)"></div>

要获取粘贴的文本,必须使用getData方法,如下所示:

onPaste(event) {
    console.log(event.clipboardData.getData('Text'));
}

正如我在描述中提到的,我正在尝试获取csv文件。据我所知,文件应该在event.clipboardData.items中。很遗憾,此数组为空。
onPaste(event) {
    console.log(event.clipboardData.getData('Text'));
}