在DurandalJS中,我在ViewModel中创建了一个Activator,它将绑定到View中的Compose Binding。琐碎的例子:
var ViewModel = function(){
this.childView = activator.create();
this.activate = function(whyIsThisUndefined){ console.error('Well?' + whyIsThisUndefined); }
}
<div data-bind="compose: { model : theModel, activationData: [1]}"></div>
我做错了什么?为什么Durandal不通过激活参数?
答案 0 :(得分:3)
当您为视图模型使用Singleton时,我不认为这些参数会在以后每次都传递给activate函数。传递您的数据 -
activationData: { data: 'Hey!!!!' }
确保每次都在原型上创建激活并创建视图模型(或AMD模块)的新实例。