I've been attempting to invoke a function from within a timed function called by setInterval().
Here's the snippet of my code:
export class SmileyDirective
{
FillGraphValues()
{
console.log("The FillGraphValues function works as expected"); // this works
}
MyTimer()
{
console.log("The timer is functioning properly"); // this works
this.FillGraphValues(); // this does not work
FillGraphValues(); // this does not work
}
draw()
{
this.FillGraphValues(); // this works
setInterval(this.MyTimer, 1000);
}
}
The application 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 unfortunately, none of these approaches worked.
Your assistance would be greatly appreciated! :)