在DurandalJS中,我在ViewModel中创建了一个激活器,它将与视图中的Compose绑定绑定。微不足道的例子:DurandalJS组合绑定不传递activationData到子视图模型
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为什么不通过激活参数?
检查这篇文章 - http://pwkad.wordpress.com/2014/02/02/best-parts-about-durandal/ –
嘿,PW,卡德,我其实只是读了那篇文章。我意识到这种语法,并在我的搜索引擎中发现了它的几处引用,但即使使用硬编码值,也没有任何内容传递给我的激活方法。你有一个我能看到的工作例子吗?你在用什么版本的Durandal? (对我来说是2.0.1)。 –
2.0.1。你可以将激活数据更改为activationData:{data:'Hey !!!!' }然后console.log(whyIsThisUndefined)并查看该对象上是否有数据属性? –