I have implemented an uploading function in my parent component. As I set up tinymce, I connected the [init] property of my component to the loadConfig() function.
<editor [(ngModel)]="data" [init]="loadConfig()"></editor>
The loadConfig function includes the images_upload_handler as follows:
images_upload_handler: function (blobInfo, success, failure) {
const code = this.upload(blobInfo);
if (code !== 0) {
success(code);
} else {
failure(code);
}
}
However, when attempting to upload something, I receive an error stating that 'upload' is undefined. This issue seems to stem from a change in scope for 'this'.
My attempt to address this involved listening for the (onInit) event and updating the function reference with the following code:
event.editor.settings.images_upload_handler = this.Upload;
Yet now I am facing errors mentioning that 'this.apiService' is undefined, indicating that the correct scope is still not being used.
I considered utilizing XMLHttpRequest(), but would need security tokens to proceed. Instead, I prefer to leverage the apiService I have created. How can I utilize the images_upload_handler without losing access to my apiService's scope?