1

Ember.jsの主な機能をテストしています。提供されているガイドによると、次のコードは、単にバインディングと自動更新テンプレートを使用して出力する必要がありますHey there! This is My Ember.js Test Application!が、代わりにを出力しますHey there! This is !

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>

私が間違っていることはありますか?

4

1 に答える 1

2

viewテンプレートからビューのプロパティを参照しているため、キーワードを前に付ける必要があります。

だから試してみてください

<script type="text/x-handlebars" data-template-name="application">
  <h1>Hey there! This is <b>{{view.name}}</b>!</h1>
</script>

動作するはずです。

ああ、私は何かを忘れています、バインディングが間違っています、あなたはクラスではなくオブジェクトを参照しなければなりません。試す

Application.constants = Ember.Object.create({
  name: 'My Ember.js Test Application'
});

Application.ApplicationView = Ember.View.extend({
  templateName: 'application',
  nameBinding: 'Application.constants.name'
});
于 2012-12-27T18:11:42.490 に答える