My class has a property:
public requestLoadPersonal: Personal[] = [];
As well as a method:
private filterByGender(selectedValue: any): void {
console.log(this.requestLoadPersonal);
this.requestLoadPersonal = this.requestLoadPersonal.filter(
(p: Personal) => {
return selectedValue ? p.gender == selectedValue : true;
}
);
}
In the constructor of my class, I initialize:
public filterFn = {
name: this.filterByGender
}
I am puzzled by why when I call the function this.filterByGender
from the object filterFn
using its key, I receive an undefined message. The variable this.requestLoadPersonal
seems to be unavailable inside:
console.log(this.requestLoadPersonal);
?
The method is called like this:
this.filterFn['name']({...});
I have attempted to bind the variable:
this.filterFn['name']({...}).bind(this.requestLoadPersonal);