2012-03-02 87 views

回答

1

句柄模板將在渲染時在視圖的上下文中進行評估。因此,如果您想直接引用{{realName}},則需要在視圖上定義realName。如果你想在其他一些範圍內評估realName,比如App,只需指定它爲:{{App.realName}}

我不完全神交你的榜樣的意圖,但你可能想要做這樣的事情來存儲你的看法你的「小部件」的對象:

App[a + "Widget"] = Ember.Object.create({realName: b.name}) 
App[a + "View"] = Ember.View.create(
    appWidget: App[a + "Widget"] 
    tagName: b.tag 
    template: Ember.Handlebars.compile '{{appWidget.realName}}' 
) 
+0

真棒,太感謝你了。在迭代json數據模型時,我嘗試創建Ember對象並實時查看。 – lilyfrommars 2012-03-02 19:22:26

相關問題