hi i have a problem with es6 and in particulary the methods of class. See my exemple :
my first class :
class A{
constructor(){
this.B = new B();
this.test = 5;
}
methodA1(){
B.methodB1(this.methodA2);
}
methodA2(){
console.log(this.test);
}
}
the second class :
class B{
methodB1(callback){
$.get("url",function(data){
...
callback();
});
}
}
When you execute methodA1, the code return : this is undefined (in a methodeA2) ! In fact when you call a callback function in ajax call the callback lost the context of class. Somebody have an idea to skirt this problem ?
Thanks.