I am trying to call a function from inside a timed function called by setInterval().
Here is my code:
export class SmileyDirective
{
FillGraphValues()
{
console.log("FillGraphValues works"); // this works
}
MyTimer()
{
console.log("timer works"); // this works
this.FillGraphValues(); // this does not work
FillGraphValues(); // this does not work
}
draw()
{
this.FillGraphValues(); // this works
setInterval(this.MyTimer, 1000);
}
}
The App crashes with either:
"this.FillGraphValues is not a function"
or
Cannot find name 'FillGraphValues'. Did you mean the instance member 'this.FillGraphValues'?
I even tried:
setInterval(function(){MyTimer()}, 1000);
and
setInterval(function(){this.MyTimer()}, 1000);
But they didn't work.
Many Thanks :)