2

I have class with name of ArticleDialogBox in constructor of that i create the anonymous class that implement some interface i want to access a method with name of articleSelected from ArticleDialogBox how is possible to access that?

export class ArticleDialogBox {
private articlesListBox: ListBox = new ListBox();
private titleTextBox: TextBox = new TextBox();
private saveButton: Button = new Button();

constructor() {
    this.articlesListBox.addEventHandler(new class implements EventHandler {
        handle(): void {
           //how can i  access a method in ArticleDialogBox.articleSelected(); 
        }
    });

  }
 articleSelected(): void {
    this.titleTextBox.setContent(this.articlesListBox.getSelection());
    this.saveButton.setEnabled(true);
 }
}
Mohsen
  • 1,295
  • 1
  • 15
  • 45

1 Answers1

3

A typical solution would be something like this:

constructor() {
    const _self = this;
    this.articlesListBox.addEventHandler(new class implements EventHandler {
        handle(): void {
           _self.articleSelected(); 
        }
    });
}
SuperStar518
  • 2,814
  • 2
  • 20
  • 35
D Pro
  • 1,756
  • 1
  • 8
  • 15