This code is in a KnockoutJS viewmodel:
function myViewModel()
{
this.prop1 = ko.observable(123);
this.prop2 = ko.observable("Hello");
..
..
}
myViewModel.prototype.func1 = function()
{
alert(this.prop1()); //works fine here
myTimer = setTimeout(function()
{
alert(this.prop1()); //this.prop1() raises an undefined error
}, 3000); //from console: Uncaught TypeError: undefined is not a function
};
Why is the property not recognized within the timer callback? Looks like a scope issue, but I can't seem to solve it.