在子组件形式中,我将图像作为输入并希望将该图像传递给父组件,并将该图像显示给父组件
答案 0 :(得分:0)
子控件-子component.ts
@Component({
selector: 'child-comp',
})
export class childComponent
{
@Output() OnImageUpload: EventEmitter<any> = new EventEmitter<any>();
constructor(){}
uploadImage(){
let imgObject:any[]=[];
//--put all your image objects inside imgObject in the form of array
this.OnImageUpload.emit(imgObject);
}
}
---------------------父组件.html
<div>
<child-comp (OnImageUpload)='processImage($event)'> </child-comp>
</div>
--------------------------- parent.component.ts
export class parentComponent{
processImage(imgObject:any){
//--play with your imgObject on parent component here
}
}