我的pape中有3个部分knockoutjs绑定
var model1= function()
{
self = this;
//somemethods here..
}
var model2= function()
{
self = this;
self.status = null;
self.id = ko.observable(1);
self.processingStatus = function ()
{
self.status = setInterval(function(){
var id = self.userId();//**self conteine link to model3**
}, 1100);
}
//somemethods here..
}
var model3= function()
{
self = this;
//somemethods here..
}
var m1 = new model1();
ko.applyBindings(m1, document.getElementById("id1"));
var m2 = new model2();
ko.applyBindings(m2, document.getElementById("id2"));
var m3= new modelHistory();
ko.applyBindings(m3, document.getElementById("id3"));
在model2中的processingStatus
方法内, self 指针continent model3数据。
它发生了什么以及如何在每个模型类中使用不同的自指针?
答案 0 :(得分:1)
你忘记了自变量'var'。
var self = this;