1
我正在测试Ember.js的主要功能。根据提供的指南,使用简单的绑定和自动更新模板的以下代码应输出Hey there! This is My Ember.js Test Application!
,但输出Hey there! This is !
。Ember.js绑定和模板
JS:
// Create the application.
var Application = Ember.Application.create();
// Define the application constants.
Application.Constants = Ember.Object.extend({
name: 'My Ember.js Test Application'
});
// Create the application controller.
Application.ApplicationController = Ember.Controller.extend();
// Create the application view.
Application.ApplicationView = Ember.View.extend({
templateName: 'application',
nameBinding: 'Application.Constants.name'
});
// Create the router.
Application.Router = Ember.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/'
})
})
})
// Initialize the application.
Application.initialize();
HBS:
<script type="text/x-handlebars" data-template-name="application">
<h1>Hey there! This is <b>{{name}}</b>!</h1>
</script>
有什么我做错了吗?
不,我还是看到同样的事情。这是没有任何修改,我使用Ember.js网站提供的入门工具包。 –
更新回答:) –
是的,事实证明我的错误是使用'Ember.Object.extend'而不是'Ember.Object.create'。还有一件事,为什么Ember.js指南在处理栏变量时忽略了'view.'前缀? –