I'm losing the context of the "This" object on the helper class on the following structure, and i can't figure out why.
Inside the getAll method, the this object is making reference to the object located on the servicesDict array on the main component.
I want that the this object refer the Entity1Utils class.
export class Entity1Utils {
public getAll(context) {
this.buildQueryParams();
// this "this" refers to the object { id: 'entity1', method: this.entity1Utils.getAll }
// located on servicesDict at ManagementComponent
}
private buildQueryParams() {
// logical code
}
}
@Component({
selector: 'app-management',
templateUrl: './management.component.html',
styleUrls: ['./management.component.css']
})
export class ManagementComponent implements OnInit {
private entity1Utils: Entity1Utils;
private servicesDict: any;
constructor() {
this.entity1Utils = new Entity1Utils();
this.servicesDict = [
{ id: 'entity1', method: this.entity1Utils.getAll }
];
}
}