2012-08-06 73 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