你用过吗
@Output()
把信息从孩子传给父母
applyGif()
在你的
GifPickerComponent
声明:
@Output() gifSelected: EventEmitter<any> = new EventEmitter<any>(); // or whatever type your are sending
applyGif(gif): any {
this.gifPickerVisible = false;
this.uploadedGif = true;
let gifMedia = gif.media[0]; // this is an json object I want to use/see in the Posting HTML Component
this.gifSelected.emit(gifMedia);
}
在
PostingComponent
正在使用的HTML模板文件
app-gifpicker
:
<app-gifpicker (gifSelected)="onGifSelected($event)"></app-gifpicker>
创建
onGifSelected
public onGifSelected(gif: any) {
// Do whatever you need to do.
this.selectedGif = gif;
}
此外,您的发布组件是父组件,它承载其他组件,如您的
GIFPickerComponent