this.twm = 5;
this.rate = 5; // but it changes dynamically with another function (not included)
rateOfMass() {
if (this.rate >= 5)
this.twm ++;
console.log(this.twm);
}
setInterval(this.rateOfMass, 1000);
the problem is
because of the setInterval function the code inside my rateOfMass function does not have access to the variables that where defined outside of it (in this case : this.twm and this.rate)
This was also the case when i tried to make the function using SetTimeout instead
the console log comes up with: undefined
does anyone know if this is just a angular2 bug and/or if there is a solution to this?
Sorry about that, just edited my post to correct that mistake it was done correctly in my actual code , I incorrectly typed it back out when writing this post