I am developing an Angular 7 app and in this app I am using the WYSIWYG editor library called Froala.
I have added a custom button to the toolbar and now I want to call a method in the same class the user clicks on this button (to open up a custom modal). I use the code below but I get an error saying it does not find the openPictureModal method.
$.FroalaEditor.DefineIcon('imagePicker', {NAME: 'info'});
$.FroalaEditor.RegisterCommand('imagePicker', {
title: 'Image picker',
focus: false,
undo: false,
refreshAfterCallback: false,
callback: function (data) {
this.openPictureModal();
}
});
I get this error:
Uncaught TypeError: this.openPictureModal is not a function
This is my modal method:
openPictureModal() {
const modalRef = this.modalService.open(PictureManageComponent, { size: 'lg' });
modalRef.componentInstance.formFinished.subscribe(($event) => {
modalRef.close();
});
}
How can I call custom methods in the same class from a custom button?