2012-08-06 44 views
1

我有以下容器Emberjs子視圖結合

script type: 'text/x-handlebars', 'data-template-name': 'application', -> 
text ''' 
{{outlet}}  
''' 

隨後這一觀點被連接到它

script type: 'text/x-handlebars', 'data-template-name': 'index', -> 
text ''' 
{{view App.SignUpView}} 
''' 

實際視圖

App.SignUpView = Ember.View.extend 
templateName: 'signup' 

isValid: true 
email: '' 
password: '' 

模板:

script type: 'text/x-handlebars', 'data-template-name': 'signup', -> 
text ''' 
    is valid: {{isValid}} 
''' 

如何將isValid字段綁定到視圖?它是未定義的。這在某種程度上與父視圖中的「出口」有關嗎?

此示例Binding child views and collections within an outlet in emberjs顯示瞭如何將任意對象綁定到視圖。

+0

相關的問題在這裏:http://stackoverflow.com/questions/11818116/ember-js-handlebars-displays-nothing – 2012-08-06 21:15:34

回答

2

你應該在你的模板中使用的視圖範圍:

is valid: {{view.isValid}} 
+0

謝謝,這是一個惡作劇! – 2012-08-08 09:10:30

+0

很高興我可以幫助:-)這是你的正確答案嗎?如果是這樣,你可以接受它。 – 2012-08-08 09:12:38