我有一个父组件,其中有 2 个输入type="file"
元素,它们getFileForParent()
在文件更改时调用函数:
<input type="file" (change)="getFileForParent()" />
在我的子组件中,我有一个:
<input type="file" (change)="getFileForChild()" />
但是每当我在子组件上选择一个文件时,getFileForParent
都会调用父母。我正在使用ng2-file-upload
.
家长 ts:
getFileForParent(){
if(this.uploaderForParent.queue[0].file.type != 'application/PDF'){
this.showError("Please select pdf files only");
return;
}
this.uploaderForParent.uploadAll();
}
儿童 ts:
getFileForChild(){
if(this.uploaderForChild.queue[0].file.type != 'application/PDF'){
this.showError("Please select pdf files only");
return;
}
this.uploaderForChild.uploadAll();
}