I have an object in javascript:
export class A{
name:string;
sayHi() {
console.log("Hi " + name);
}
}
I'm filling an array of type A using a backend service, but when I'm going to use sayHi I'm getting that the funcion is not defined:
backService.get().subscribe( (a:A) => a.sayHi());
Now my guess is that since the back end service response is just a Json it does not have a way to actually add the function reference to this object.
How can I define the "sayHi" function inside the A class so it is always available? I could create another class or a static method but I would like to have this logic encapsulated inside the class reference.
Thanks.