【发布时间】:2020-01-09 09:37:01
【问题描述】:
我有 组件 A,它会触发 MatDialog
openDialog(): void {
// console.log('The dialog was opened');
const dialogRef = this.dialog.open(PicuploadComponent, {
width: '1000px',
//data: {name: this.name, animal: this.animal}
});
dialogRef.afterClosed().subscribe(result => {
// I want to get data from upload response here! **res**
});
}
这个组件触发 PicuploadComponent 我上传图片并接收一些数据的响应
onUpload() {
const fd = new FormData();
fd.append('image', this.selectedFile);
this.service.uploadImage(fd).subscribe(
(res:any)=>
{
console.log(res) ;
this.dialogRef.close();
},
);
}
【问题讨论】:
-
我已经在对您之前问题的回答中描述了这一点...stackoverflow.com/a/57822253/2352314
-
这是一个重复的问题!见:stackoverflow.com/questions/42664974/…
标签: angular typescript components implementation data-transfer