I am trying to invoke a method from a filterfunction() by using 'this' keyword. However, I realize that 'this' refers to the event handler instead the component, and the value I get for 'this' is null so I get a runtime error.
export class SmartTableComponent {
settings = {
...
columns: {
...
firstName: {
title: 'First Name',
type: 'string',
filterFunction(cell?: any, search?: string): boolean {
return this.doFilter(cell, search);
}
},
...
},
...
};
doFilter(cell?: any, search?: string): boolean{
return true;
}
}
In Java, we would get a reference to 'this' by using SmartTableComponent.this.doFilter(...) but this does not seems to work in TypeScript.
How can I invoke a component's method from a filterFunction in ng2-smart-table?