PhotoEditorSDKコンポーネントを使用したいアプリケーションがあります。 Their demos for angular implementationは、私がこれを設定してほしいと述べています。PhotoEditorSDKからイベントを聴く角度
@Component({
selector: 'app-photo-editor',
template: `<ngui-react [reactComponent]="reactComponent" [reactProps]="reactProps"></ngui-react>`,
styleUrls: ['./photo-editor.component.scss']
})
export class PhotoEditorComponent implements OnInit {
@Input() src: string;
image = new Image();
defaultProps = {
license: license,
assets: {
baseUrl: '/assets/photoeditorsdk' // see angular-cli.json for configuraton
},
responsive: true,
style:{
width: '100%',
height: '100%'
},
editor: {
image: this.image
}
};
reactComponent: React.Component = PhotoEditorDesktopUI.ReactComponent;
reactProps: any = {...this.defaultProps};
constructor(private el: ElementRef, private translate: TranslateService) { }
ngOnInit() {
this.image.src = this.src;
}
}
これは問題なく動作します。私はAngularアプリでレンダリングされたReactコンポーネントを取得します。これで、レンダリングされたオブジェクトにイベントリスナーを登録します。彼らは、少なくともexport
イベントを公開Their documentation状態:
editor.on('export', (result) => {
console.log('User clicked export, resulting image/dataurl:', result)
})
しかし、私はeditor
を自分で作成しないでください。このオブジェクトはngui-react
にコンポーネントタイプを送信することによって作成され、このディレクティブ内に作成されます。作成したPhotoEditorSDKオブジェクトを保持するにはどうすればよいのですか?イベントリスナーを置くことができますか?
私は
this.reactComponent.on(....)
しかしPhotoEditorDesktopUI !== this.reactComponent
にイベントリスナーを設定しようとしました。 reactComponent
は、作成されたPhotoEditorDesktopUI
オブジェクトのコンテナです。