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.'前綴? –