I seem to be losing the reference to the "This" object within the helper class in this particular structure, and I'm not sure why.
When looking at the getAll method, the this object is currently pointing to the object housed within the servicesDict array within the main component.
What I am aiming for is for the this object to instead refer to the Entity1Utils class.
export class Entity1Utils {
public getAll(context) {
this.buildQueryParams();
// The usage of "this" points to the object { id: 'entity1', method: this.entity1Utils.getAll }
// found within servicesDict in 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 }
];
}
}